Pagini recente » Istoria paginii runda/xxx | Cod sursa (job #2843901) | Cod sursa (job #429557) | Cod sursa (job #1280996) | Cod sursa (job #3289274)
#include <iostream>
using namespace std;
const int INF = 1e9;
int main()
{
int n, ans, l, r;
cin >> n;
l = 0, r = n;
while( l < r - 1 ) {
int mij = ( l + r ) / 2;
cout << "? " << mij << " " << endl;
cout.flush();
cin >> ans;
if( ans == - 1 )
break;
else if( ans == 0 )
l = mij;
else
r = mij;
}
cout << "! " << r << " " << endl;
cout.flush();
return 0;
}