Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
【Problem Description】
A total of two query, query given every \ (100 \) different numbers, for each query evaluation system, the random (100 \) \ choosing for a number of \ (A \) , returns \ ( the X-\ oplus A \) . Let you pass the value returned twice guess \ (x \) value is. Requires two inquiry \ (200 \) number different from each other, and entitled ensure \ (X \) value is fixed.
【Solution】
Title all challenge data required, namely \ (X \) values in \ ([0,2 ^ {14} -1] \) in the range of, and only two interrogation, according to the nature of XOR, \ (0 \) exclusive-or any number does not change. So you can get an answer in two, that is, for the first time to determine \ (x \) binary high \ (7 \) high when the bit, which is the first inquiry, the number of all queries \ (7 \) Bit are all \ (0 \) , thus ensuring a high evaluation system selected from any number returns a value after exclusive-oR \ (7 \) bit constant with \ (X \) high \ (7 \) the same bit. Similarly, the secondary as long as all the low number of inquiries \ (7 \) bits are all \ (0 \) , you will eventually get twice the value of the merger can be.
【Code】
/*
* @Author: Simon
* @Date: 2019-08-27 20:36:36
* @Last Modified by: Simon
* @Last Modified time: 2019-08-27 21:57:17
*/
#include<bits/stdc++.h>
using namespace std;
typedef int Int;
#define int long long
#define INF 0x3f3f3f3f
#define maxn 200005
int a[maxn];
Int main(){
#ifndef ONLINE_JUDGE
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout<<"? ";
for(int i=1;i<=100;i++) cout<<i<<" "; //第一次保证高7位为0
cout<<endl;
int ans;cin>>ans;
ans|=127; //低7位全置1
cout<<"? ";
for(int i=1;i<=100;i++) cout<<(i<<7)<<' ';//第二次保证低7为0
cout<<endl;
int tmp;cin>>tmp;
(ans&=(tmp|(127<<7))); //合并第二次的低7位
cout<<"! "<<ans<<endl;
#ifndef ONLINE_JUDGE
cout<<endl;system("pause");
#endif
return 0;
}