Cod sursa(job #2798752)
Utilizator | Data | 11 noiembrie 2021 20:16:31 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
int query( int x ) {
cout << "? " << x << endl;
cin >> x;
return x;
}
int cb( int st, int dr ) {
int mij;
while ( st < dr - 1 ) {
mij = ( st + dr ) / 2;
if ( query( mij ) == 0 ) {
st = mij;
} else
dr = mij;
}
return dr;
}
int main () {
int n;
cin >> n;
cout << "! " << cb( 0, n ) << endl;
return 0;
}