Cod sursa(job #3288283)
Utilizator | Data | 21 martie 2025 12:32:19 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
int n, st, dr, poz;
int main() {
cin >> n;
st = 0;
dr = n;
while(st <= dr) {
int mij = st + (dr - st) / 2;
cout << "? " << mij << endl;
cout.flush();
int x;
cin >> x;
if(x == 0) {
poz = mij;
st = mij + 1;
}
else dr = mij - 1;
}
cout << "! " << poz << endl;
cout.flush();
return 0;
}