#P15427. Nobody Tells (Original Version)
Nobody Tells (Original Version)
Background
Problem Description
Please note the differences between this problem and P15425 Nobody Tells — this problem has stricter constraints on queries.
This is an interactive problem.
Coola has two numbers , and a prime number . We generate a sequence in the following way:
$$\begin{cases} f_{0}=1\\ f_{1}=p\\ f_{i}=(pf_{i-1}+qf_{i-2})\bmod M,&i>1 \end{cases}$$The interactive judge will give you and a parameter . You can query the judge at most times:
- Provide an index , and the judge tells you the value of .
Your task is to guess the value of after at most queries. In particular, you may guess two pairs of at the same time, see the interaction details.
Interaction Details
This problem contains multiple test cases.
In the first line of the input, the judge will give your program an integer , meaning the number of test cases in this test point.
For each test case:
The judge will have the for this test case. This also means the judge is non-adaptive.
In the first line, the judge inputs two integers to your program, meaning the modulus and the query restriction.
For each query, you need to output ? i, meaning querying the value of .
Under normal conditions, the judge will input an integer in , which is the you queried.
If any of the following happens, the judge will immediately terminate the interaction and force your program to exit, and this test point will be judged as failed:
- The number of queries exceeds .
- is not in the range .
After you have guessed the possible , you need to output ! p1 q1 p2 q2, meaning the two pairs of you guess are and . This operation does not count toward the queries. In particular, you must ensure that all four numbers are in the range , otherwise the judge will immediately terminate the interaction and force your program to exit, and this test point will be judged as failed.
If at least one of the two answer pairs matches the value held by the judge, then this test case is passed; otherwise it is failed, and the judge will immediately terminate the interaction and force your program to exit.
If you pass all test cases in a test point, then this test point will be judged as passed.
1
5 1
3
1
? 1
? 2
! 3 2 1 1
Hint
Explanation of Sample #1
The data held by the judge is .
In the first interaction, your program queries the value of with . Clearly , so the judge inputs to your program.
In the second interaction, your program queries the value of with . We have . Therefore the judge inputs to your program.
Since , and we know , we can solve . So you have determined the answer using two queries, and you can output . Since the first pair of answers is correct, the second pair does not matter, so is also a valid output. However, or are not, because you must ensure all four numbers are in the range .
Constraints
This problem uses bundled tests.
For of the data, . , and is guaranteed to be prime. .
The judge is non-adaptive, and .
| Subtask | Special Property | Score |
|---|---|---|
| 1 | ||
| 2 | and | |
| 3 | ||
| 4 | and | |
| 5 | None |
Afterword
:::epigraph[——《Nobody Tells》]
The lights that guide the way along the journey
You are one of them
:::
Translated by ChatGPT 5