Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-Interactive Questions
[Problem Description]
? A total of two queries, each query gives a difference of \(100\) For each inquiry, the evaluation system randomly selects a number from the number of \(100\)\(a\) , return to \(x\oplus a\). Let you guess what the value of \(x\) is from the value returned twice. The number of \(200\) required to be asked twice is different, and the question is guaranteed to be \(x\) The value is fixed.
[Solution]
? The question requires all inquiry data, which is the value of \(x\) Within the range of \([0,2^{14}-1]\), and can only be asked twice, according to the nature of XOR, \(0\) XOR any number will not change. So you can get the answer twice, that is, first determine the high of \(x\) in binary \(7\) digits, that is, the high \(7\) digits of all the queries in the first query are all \(0\), so as to ensure that the high \(7\) bit of the value returned after the evaluation system selects any number XOR must be the same as the \(7\) of “math inline”>\(x\) is the same, and the same is true. For the second time, just ensure that all the numbers in question are The low \(7\) bits are all \(0\), and finally the two values obtained are combined. Can.
[Code]
/* * @Author: Simon * @Date: 2019-08-27 20:36: 36 * @Last Modified by: Simon * @Last Modified time: 2019-08-27 21:57:17 */#includeusing namespace std;typedef int Int;#define int long long#define INF 0x3f3f3f3f#define maxn 200005int 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<>ans; ans|=127; //The lower 7 bits are all set to 1 cout<<"? "; for(int i=1 ;i<=100;i++) cout<<(i<<7)<<'';//The second guarantee that the lower 7 is 0 cout< >tmp; (ans&=(tmp |(127<<7))); //Merge the lower 7 bits of the second cout<<"! "<