| MEPhI Spring Cup 2025 |
|---|
| Finished |
This is an interactive problem
While contemplating various simple pseudo-random number generators, Andrew-13 decided to consider a linear generator characterized by parameters $$$a$$$, $$$b$$$, and $$$p$$$ ($$$1 \le a \lt p$$$, $$$0 \le b \lt p$$$, $$$p$$$ is a prime number, $$$2 \le p \lt 10^9$$$). The generator takes time $$$t$$$ as input and outputs $$$(at + b) \mod p$$$.
To demonstrate the unreliability of such a generator, Andrew-13 decided to write a program that, without knowing the numbers $$$a$$$, $$$b$$$, and $$$p$$$, finds them by making queries to the generator. The program is allowed to make no more than $$$13$$$ queries.
Can you write your own program that can solve this task?
At the beginning of each test, the numbers $$$a$$$, $$$b$$$, and $$$p$$$ are chosen according to the constraints given.
Then your program begins interaction with the interactor.
To find out the value of the pseudo-random number generator described in the problem, you should output «? $$$t$$$» on a separate line ($$$0 \le t \lt 10^{18}$$$, $$$t$$$ is an integer). You will receive the value $$$(at + b) \mod p$$$.
When your program is ready to provide an answer, it must output «! $$$a$$$ $$$b$$$ $$$p$$$» on a separate line and then terminate.
If you make more than $$$13$$$ queries during the interaction, your program should terminate immediately, and you will receive a Wrong Answer verdict. Otherwise, you may receive any verdict.
After each query output, do not forget to print a newline and flush the output buffer. To do this, use:
13 4 12
? 6 ? 12 ? 998244353 ! 7 5 17
| Name |
|---|


