daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Dec 4th, 2018 1,034 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top