#include using namespace std; int ask(int Y){ cout << "? " << Y << endl << flush; int res; cin >> res; return res; } void answer(int Y){ cout << "! " << Y << endl << flush; } int main(){ if(ask(100) <= 0){ for(int i = 1;;i++){ if(ask(0) == 0){ answer(i); return 0; } } } // l inclusive, r exclusive int l = 10, r = 1000000001; int cnt = 1; while(r-l > 1){ int mid = (l+r)/2; switch(ask(mid)){ case -1: r = mid-1; break; case 1: l = mid; break; case 0: answer(mid+cnt-1); return 0; } cnt++; } answer(l + cnt-1); return 0; }