#CF1665D. GCD Guess
GCD Guess
题面翻译
感谢
这是一道交互题。
有一个正整数 ,你必须将它猜出来。
每次查询,你可以选择两个数 ,你会从交互库得到 。
你要在 次猜测之内得到 。
交互格式
第一行输入一个整数 ,表示测试用例的数量,即猜测次数。
每次猜测时格式为 ? a b
,此时你将得到 。
当你确定答案,你可以输出 ! x
,然后继续解决下一个测试用例。
题目描述
This is an interactive problem.
There is a positive integer that you have to guess.
In one query you can choose two positive integers . As an answer to this query you will get , where is the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest common divisor) of the numbers and .
To guess one hidden number you are allowed to make no more than queries.
输入格式
The first line of input contains a single integer ( ) denoting the number of test cases.
The integer that you have to guess satisfies the constraints: ( ).
输出格式
The hidden number is fixed before the start of the interaction and does not depend on your queries.
To guess each you can make no more than queries in the following way:
- "? a b" ( , ).
For this query you will get .
When you know , print a single line in the following format.
- "! x" ( ).
After that continue to solve the next test case.
If you ask more than queries for one or make an invalid query, the interactor will terminate immediately and your program will receive verdict Wrong Answer.
After printing each query do not forget to output end of line and flush the output buffer. Otherwise, you will get the Idleness limit exceeded verdict. To do flush use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- Read documentation for other languages.
Hacks
To use hacks, use the following format of tests:
The first line should contain a single integer ( ) — the number of test cases.
The first and only line of each test case should contain a single integer ( ) denoting the integer that should be guessed.
样例 #1
样例输入 #1
2
1
8
1
样例输出 #1
? 1 2
? 12 4
! 4
? 2000000000 1999999999
! 1000000000
提示
The first hidden number is , that's why the answers for the queries are:
"? 1 2" — .
"? 12 4" — .
The second hidden number is , that's why the answer for the query is:
"? 2000000000 1999999999" — .
These queries are made only for understanding the interaction and are not enough for finding the true .