Cod sursa(job #2806436)
Utilizator | Data | 22 noiembrie 2021 17:30:42 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("cbinteractiv.in");
ofstream g("cbinteractiv.out");
int n;
int st,dr,mij;
int x;
int main()
{
cin >> n;
st=1, dr=n;
while (st!=dr) {
mij = (st+dr)/2;
cout << "? " << mij << '\n';
cin >> x;
if (x==1) {
dr = mij;
}
else {
st = mij+1;
}
}
cout << "! " << st;
return 0;
}