#P11144. 「SFMOI Round I」Strange Madoka Game

    ID: 10442 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数论洛谷原创交互题Special JudgeO2优化不定方程洛谷月赛

「SFMOI Round I」Strange Madoka Game

Description

This problem is different from B2. You had better read both statements.

This is an interactive problem.

Hint: We provide a formalized description of this problem at the end of the statement.

Madoka and Homura are playing a game.

Madoka has thought of a non-negative integer mm, and Homura need to determine its value. It is guaranteed that 0m1017\textcolor{red}{0}\le m\le 10^{17}. Also, Madoka doesn't cheat, that is, Madoka wouldn't change the value of mm during the whole game.

Homura can ask Madoka: for a positive integer xx, what is the value of mmodxm\bmod x. Homura aims to determine the value of mm with the number of queries as small as possible. (In order to get full points, you need to solve this problem within 22 queries.)

The game will be played for TT rounds. However, Homura is poor at math. Thus, she turns to you.

Formally, there exists a hidden non-negative integer m[0,1017]m\in [\textcolor{red}{0},10^{17}]. In each query, a positive integer xx is given, and it returns mmodxm \bmod x.

Find mm with the least number of queries. There are TT test cases.

The value of mm is read from input file and does not change according to queries. That is, the interactor is non-adaptive.

Implementation Details

Input a positive integer TT first, which stands for the number of the rounds.

For each test case:

  • Output a single line containing ? x\texttt{? }x to make a query. Then, an integer indicating mmodxm\bmod x is available.

    xx is a positive integer should be guaranteed, and xx must fall in [1,4×108] \textcolor{red} {[1,4\times 10^8]}.

    If x=1x=-1 instead of the answer, it means that the query limit is excceeded, or the query is invalid. The solution should quit immediately.

  • Output a single line containing ! m\texttt{! }m to respond to the guess.

After outputing the queries, do not forget to output a newline character and flush the output buffer. Otherwise, you will receive the verdict TLE. To flush the buffer, use:

  • fflush(stdout) or cout.flush() in C++;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • refer to the documentation for other languages.

Input Format

See [Implementation Details].

Output Format

See [Implementation Details].

1

1

2

? 2

? 3

! 5

Hint

Constraints

It is guaranteed that

  • 1T1001\le T\le 100;
  • mm is a non-negative number, and 0m1017\textcolor{red}{0}\le m\le 10^{17}

Scoring

Let QQ be the maximum queries used in each test. The score\mathrm{score} is calculated as following:

$$\begin{aligned} \mathrm{score}=\begin{cases} 0, & Q\in [81,+\infty) \\ 10, & Q\in [11,81) \\ 25, & Q\in [3,11) \\ 50, & Q\in [0,3) \\ \end{cases} \end{aligned}$$

The score of this problem is the minimum score among all tests.