#P10699. [SNCPC2024] 猜质数 I
[SNCPC2024] 猜质数 I
Problem Description
This is an interactive problem.
MCPlayer542 has a mysterious odd prime , but he does not want you to know what it is.
He plans to use a function to encrypt his number. The value of is the sum of the decimal digits of . For example, , , and .
However, since you are too smart, he thought about it and decided to change the encryption function to:
That is, apply continuously times, and replace the in his hand with .
Now he is going to give you integers , and he wants you to tell him what
$$q^{a_1}\bmod (m\cdot a_1),\ q^{a_2}\bmod (m\cdot a_2),\ \ldots,\ q^{a_n}\bmod (m\cdot a_n)$$are, respectively. He thinks you definitely cannot guess it, so he decides to let you choose and yourself. Can you complete this task?
Note: The range of has special constraints.
Input Format
The input contains multiple test cases. The first line contains an integer (), indicating the number of test cases. The interactive process for each test case is described below.
In each test case, the first line contains two integers and (), separated by a single space, with meanings as described in the statement.
Then, for each interaction, output one integer per line ( are pairwise distinct), indicating the exponent of you want to query.
After making a query, you should read an integer, which is .
After finishing rounds of interaction, you need to output one integer in one line (), then output numbers in the next line: $q^{a_1}\bmod (m\cdot a_1), \ q^{a_2}\bmod (m\cdot a_2), \ \ldots, \ q^{a_n}\bmod (m\cdot a_n)$, separated by single spaces, as the answer.
You must perform exactly rounds of interaction, then output the answer and terminate the program, otherwise you may get unpredictable results.
Note that at the end of each output in your program (that is, each time you output for an interaction, and when you finally output and the answers), you need to print a newline and flush the output buffer. Otherwise, you will get .
- In C: ;
- In C++: ;
- In Java: ;
- In Python: ;
to flush the output buffer.
It is guaranteed that the odd prime () in each test case is fixed before the interaction starts, and will not change with your input.
If your final output is correct, you will get .
If your or do not satisfy the constraints, or your final output is incorrect, you will get .
In addition, other verdicts will still be returned during judging according to the usual situations.
2
3 1
3
9
9
3 2
4
4
4
1
2
3
100
3 9 27
1
7
49
49
0 0 0
Hint
In the first test case, the odd prime in MCPlayer542's hand, so .
We choose the array , and obtain in order.
Then we guess and choose , so we output $3^1\bmod (100\times 1)=3, \ 3^2\bmod (100\times 2)=9, \ 3^3\bmod (100\times 3)=27$.
In the second test case, the odd prime in MCPlayer542's hand, so .
We choose the array , and obtain in order.
Then we keenly notice and choose , so we output $49^1\bmod (49\times 1)=0, \ 49^7\bmod (49\times 7)=0, \ 49^{49}\bmod (49\times 49)=0$.
Note: The phrase “keenly notice” in the second test case is only used as an illustration of the interactive process, and does not guarantee that the above interaction can determine that .
Translated by ChatGPT 5