题解:P14750 月影戀
前情提要
“戀”字读 liàn 。应该很多人都没去查吧
思路
题目的主要意思就是让我们用
既然是
求出二进制的哪几位是 1,可以用
细心的你们应该能发现,只要用一个足够大的 2 的次方,与我们所要求的
接下来,把
看看数据范围
在上文中,
要最终求出
理论存在,实践开始。
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//int lowbit(int x){
// return x & -x;
//}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
ll a = pow(2, 60);
while(t --){
ll num = 0,g;
while(true){
cout<< "? " << a << " " << a - num << endl;
cout.flush();
cin >> g;
cout.flush();
if(g == a){
break;
}
num += g;
}
cout << "! " << num << endl;
}
return 0;
}