AtCoder Grand Contest 075
翻译中…
Problem Statement
翻译中…
You are given two length-$N$ sequences of non-negative integers: $A=(A_1,A_2,\dots,A_N)$ and $B=(B_1,B_2,\dots,B_N)$.
翻译中…
For a permutation $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$, define the cost of $P$ as $\sum_{i=1}^{N} \left \lfloor \frac{A_{P_i}}{2^{B_i}} \right \rfloor$.
翻译中…
Find the number, modulo $998244353$, of permutations $P$ that achieve the minimum cost.
翻译中…
You are given $T$ test cases; solve each of them.
翻译中…
Constraints
翻译中…
$1 \le T \le 2 \times 10^5$$1 \le N \le 2 \times 10^5$$1 \le A_i \le 10^9$$0 \le B_i \le 30$- The sum of
$N$over all test cases is at most$2 \times 10^5$.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
翻译中…
Each test case is given in the following format:
翻译中…
N
A_1\ A_2\ \dots\ A_N
B_1\ B_2\ \dots\ B_N
翻译中…
Output
翻译中…
Output $T$ lines. The $i$-th line $(1 \le i \le T)$ should contain the answer for $\mathrm{case}_i$.
翻译中…
样例
Input #1
7
2
5 9
0 1
3
3 4 10
0 1 2
4
1 2 3 4
0 0 1 1
5
1000000000 1000000000 1000000000 1000000000 1000000000
0 0 0 0 0
11
19 68 97 62 99 52 57 19 43 80 96
5 3 3 2 3 4 3 2 3 4 3
14
86 49 83 31 5 43 7 46 98 36 60 4 69 59
3 1 4 4 4 0 1 3 0 4 3 5 1 2
10
907139744 237517128 852012347 350549430 62876062 196019710 263351472 184393437 281593038 753973502
23 12 1 26 29 24 0 7 10 4
Output #1
1
2
4
120
8640
15552
1
For the first test case, the cost for each $P$ is as follows:
- For $P=(1,2)$, $\left \lfloor \frac{A_{1}}{2^{B_1}} \right \rfloor + \left \lfloor \frac{A_{2}}{2^{B_2}} \right \rfloor = \left \lfloor \frac{5}{1} \right \rfloor + \left \lfloor \frac{9}{2} \right \rfloor = 9$
- For $P=(2,1)$, $\left \lfloor \frac{A_{2}}{2^{B_1}} \right \rfloor + \left \lfloor \frac{A_{1}}{2^{B_2}} \right \rfloor = \left \lfloor \frac{9}{1} \right \rfloor + \left \lfloor \frac{5}{2} \right \rfloor = 11$
Thus, the minimum cost is $9$, and there is one permutation $P = (1,2)$ that achieves it.
For the second test case, $P = (1,2,3),(2,1,3)$ achieve the minimum cost of $7$.
For the third test case, $P = (1,2,3,4),(2,1,3,4),(1,2,4,3),(2,1,4,3)$ achieve the minimum cost of $6$.
For the fourth test case, all permutations of $(1,2,3,4,5)$ achieve the minimum cost of $5000000000$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。