시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
10 초 | 512 MB | 0 | 0 | 0 | 0.000% |
Suppose you have $n$ pairwise different numbers on a desk, denoted by $a_1, a_2, \ldots, a_n$ (order matters). In one turn, you can choose two different indices $i_1 < i_2$ and simultaneously increase $a_{i_1}$ and $a_{i_2}$ by one. The only condition is that the numbers on the desk should be different in every moment. Your task is to find the number of ways to obtain pairwise different numbers $b_1, b_2, \ldots, b_n$ (in exactly this order). As this number can be very large, print it modulo $998\,244\,353$.
The first line of the input contains a single integer $n$ ($1 \le n \le 30$). The second and the third lines of the input contain $n$ space-separated integers each: the arrays $a_i$ and $b_i$ respectively ($1 \le a_i, b_i \le 200$). All $a_i$ are guaranteed to be pairwise different, same for $b_i$.
Print the answer modulo prime number $998\,244\,353$.
3 1 2 3 3 4 5
1
3 1 2 3 7 8 9
42
3 1 4 7 3 6 9
6
In the first sample, the only way is to make operations in the order $\{2, 3\}, \{1, 3\}, \{1, 2\}$.
In the third sample, we can make the three operations $\{1, 2\}, \{2, 3\}, \{1, 3\}$ in any order.