Pagini recente » Cod sursa (job #225733) | Cod sursa (job #3001675) | Diferente pentru problema/entropy intre reviziile 9 si 10 | Cod sursa (job #1416202) | Cod sursa (job #3289275)
#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;
cout.flush();
cin >> ans;
if( ans == - 1 )
break;
else if( ans == 0 )
l = mij;
else
r = mij;
}
cout << "! " << r;
cout.flush();
return 0;
}