编程介的小学生 2019-05-11 00:27 采纳率: 20.5%
浏览 162

置换组合的排序算法问题,怎么利用C程序的代码编写技术实现序列的位置的求解?

Problem Description
Accidentally, Cupid, god of desire has hurt himself with his own dart and fallen in love with Psyche.

This has drawn the fury of his mother, Venus. The goddess then throws before Psyche a great mass of mixed crops.

There are n heaps of crops in total, numbered from 1 to n.

Psyche needs to arrange them in a certain order, assume crops on the i-th position is Ai.

She is given some information about the final order of the crops:

  1. the minimum value of A1,A2,...,Ai is Bi.

  2. the maximum value of A1,A2,...,Ai is Ci.

She wants to know the number of valid permutations. As this number can be large, output it modulo 998244353.

Note that if there is no valid permutation, the answer is 0.

Input
The first line of input contains an integer T (1≤T≤15), which denotes the number of testcases.

For each test case, the first line of input contains single integer n (1≤n≤105).

The second line contains n integers, the i-th integer denotes Bi (1≤Bi≤n).

The third line contains n integers, the i-th integer denotes Ci (1≤Ci≤n).

Output
For each testcase, print the number of valid permutations modulo 998244353.

Sample Input
2
3
2 1 1
2 2 3
5
5 4 3 2 1
1 2 3 4 5

Sample Output
1
0

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥30 用arduino开发esp32控制ps2手柄一直报错
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题