Guest User

Untitled

a guest
Dec 4th, 2018
2,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int ask(int c,int d)
  4. {
  5.     cout << "? " << c << ' ' << d << endl;
  6.     int ans;
  7.     cin >> ans;
  8.     return ans;
  9. }
  10. int main()
  11. {
  12.     cout.flush();
  13.     int a=0,b=0,big=ask(0,0);
  14.     for (int i=29;i>=0;i--)
  15.     {
  16.         int f=ask(a^(1<<i),b),s=ask(a,b^(1<<i));
  17.         if (f==s)
  18.         {
  19.             if (big==1)
  20.             a^=(1<<i);
  21.             else
  22.             b^=(1<<i);
  23.             big=f;
  24.         }
  25.         else if (f==-1)
  26.         {
  27.             a^=(1<<i);
  28.             b^=(1<<i);
  29.         }
  30.     }
  31.     cout << "! " << a << ' ' << b << endl;
  32. }
Add Comment
Please, Sign In to add comment