Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int ask(int c,int d)
- {
- cout << "? " << c << ' ' << d << endl;
- int ans;
- cin >> ans;
- return ans;
- }
- int main()
- {
- cout.flush();
- int a=0,b=0,big=ask(0,0);
- for (int i=29;i>=0;i--)
- {
- int f=ask(a^(1<<i),b),s=ask(a,b^(1<<i));
- if (f==s)
- {
- if (big==1)
- a^=(1<<i);
- else
- b^=(1<<i);
- big=f;
- }
- else if (f==-1)
- {
- a^=(1<<i);
- b^=(1<<i);
- }
- }
- cout << "! " << a << ' ' << b << endl;
- }
Add Comment
Please, Sign In to add comment