Cod sursa(job #3289275)
Utilizator | Data | 26 martie 2025 12:40:26 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#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;
}