Cod sursa(job #2784384)
Utilizator | Data | 16 octombrie 2021 13:15:22 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
using namespace std;
int main() {
int n, st, dr, mijl, rasp;
cin >> n;
st = 1;
dr = n;
while (dr-st>0) {
mijl = (st+dr)/2;
cout << "? " << mijl << '\n';
cout.flush();
cin >> rasp;
if (rasp==0) {
st = mijl+1;
} else {
dr = mijl;
}
}
cout << "! " << st <<' \n';
return 0;
}