CF1088D.Ehab and another another xor problem
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem!
Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with:
- 1 if a⊕c>b⊕d.
- 0 if a⊕c=b⊕d.
- -1 if a⊕c<b⊕d.
Operation a⊕b is the bitwise-xor operation of two numbers a and b.
Laggy should guess (a,b) with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab.
It's guaranteed that 0≤a,b<230.
这是一个交互式问题!
Ehab 和 Laggy 玩一个游戏。Ehab 心中隐藏着两个整数 (a,b)。Laggy 可以提出一对整数 (c,d),Ehab 将回答:
- 若 a⊕c>b⊕d,则返回
1; - 若 a⊕c=b⊕d,则返回
0; - 若 a⊕c<b⊕d,则返回
-1。
其中运算 a⊕b 表示两个数 a 和 b 的按位异或(bitwise-xor)运算。
Laggy 最多可提问 62 次,需猜出 (a,b)。你将扮演 Laggy,而交互器(interactor)代表 Ehab。
保证 0≤a,b<230。
输入格式
See the interaction section.
参见交互部分。
输出格式
To print the answer, print "! a b" (without quotes). Don't forget to flush the output after printing the answer.
要输出答案,请打印 ! a b(不带引号)。打印答案后,别忘了刷新输出。
输入输出样例
输入#1
1 -1 0
输出#1
? 2 1 ? 1 2 ? 2 0 ! 3 1
说明/提示
In the sample:
The hidden numbers are a=3 and b=1.
In the first query: 3⊕2=1 and 1⊕1=0, so the answer is 1.
In the second query: 3⊕1=2 and 1⊕2=3, so the answer is -1.
In the third query: 3⊕2=1 and 1⊕0=1, so the answer is 0.
Then, we printed the answer.
在样例中:
隐藏的数字为 a=3 和 b=1。
第一次查询:3⊕2=1 且 1⊕1=0,因此答案为 1。
第二次查询:3⊕1=2 且 1⊕2=3,因此答案为 -1。
第三次查询:3⊕2=1 且 1⊕0=1,因此答案为 0。
然后,我们输出了答案。
输入解题思路,AI测评打分。不知道怎么写?