#P7998. [WFOI - 01] 猜数(guess)
[WFOI - 01] 猜数(guess)
Background
This is an interactive problem. The interaction library is adaptive. Please note the special time limit.
Remember to flush the output buffer after every output.
Problem Description
You need to guess a positive integer , and it is guaranteed that .
Each time, you may make a query like ? x y, and the interaction library will deliberately choose a number from .
Then the interaction library will output an answer in the form u v, meaning that the chosen number is , and its relation to is .
Specifically:
- When the library returns , it means .
- When the library returns , it means .
- When the library returns , it means .
The cost of one query is .
You can output what you believe is the correct answer using ! x.
Now you need to determine .
Let your total cost be . The score you get on each test point depends on your total cost as follows (each test point has a full score of points):
- If , you can get .
- If , you can get $\lfloor(12-x)\times0.7 \div 1.00186965\rfloor \text{ pts}$.
- If , you can get .
Note that after every operation, you must call the following function to flush the buffer:
- For C/C++:
fflush(stdout). - For C++:
std::cout << std::flush. - For Java:
System.out.flush(). - For Python:
stdout.flush(). - For Pascal:
flush(output). - For other languages, please check the corresponding language documentation by yourself.
Interaction Format
At the beginning, the interaction library will give you .
Then you may query or answer as described above.
After you output the answer, please terminate your program immediately.
Input Format
See Interaction Format.
Output Format
See Interaction Format.
2
1 0
? 1 2
! 2
3
1 0
3 2
? 1 3
? 3 3
! 2
Hint
-
Sample Explanation:
After querying, we find that , so .
-
Sample Explanation:
After the first query, we find that .
After the second query, we find that , so .
【Constraints】
| Test Point ID | Test Point ID | ||
|---|---|---|---|
For of the testdata, , , .
It is guaranteed that each query to the interaction library runs in time.
Translated by ChatGPT 5