Cod sursa(job #3353665)
| Utilizator | Data | 9 mai 2026 12:16:07 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
using namespace std;
int main(){
int n, st, dr, mij, r;
ios::sync_with_stdio( false );
cin.tie( 0 );
cout.tie( 0 );
cin >> n;
st = 0;
dr = n;
while( dr - st > 1 ){
mij = ( st + dr ) / 2;
cout << "? " << mij << '\n';
cout.flush();
cin >> r;
if( r == 1 ){
dr = mij;
}
else{
st = mij;
}
}
cout << "! " << dr << '\n';
cout.flush();
return 0;
}