#P8565. Sultan Rage
Sultan Rage
Problem Description
There is a sequence such that for all , . Also, are positive integers given in the input.
There are queries. Each query gives a positive integer , and asks how many distinct positive-integer sets (no repeated elements) satisfy . The answer is taken modulo the prime .
This problem contains multiple test cases.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases. For each test case:
The first line contains two integers .
The second line contains integers .
The third line contains integers, where each integer represents one query.
Output Format
For each query, output one line containing the answer.
2
2 5
1 1
3 5 7 9 11
3 5
1 2 5
4 7 10 18 22
3
3
3
5
5
0
1
1
1
1
Hint
For all testdata, , , , .
$$\def\arraystretch{1.5} \begin{array}{c|c|c|c|c|c}\hline \textbf{测试点编号}&\bm{m\le}&\bm{q \le }&\bm{a_i \le }& \bm{x \le}&\bm{\textbf{特殊性质}}\cr\hline \textsf1\sim \sf2 & 8&8 & 8 & 100\cr\hline \sf3\sim 5 & 15& &15&10^3 \cr\hline \textsf6 & & & & 1 &\cr\hline \sf7\sim 11 & & 1& & & \textsf{A}\cr\hline \sf12\sim 16 & 2& & &\cr\hline \sf17\sim 20 & &\cr\hline \end{array}$$: , and is generated uniformly at random among all possible .
Translated by ChatGPT 5