Cod sursa(job #2787890)
| Utilizator | Data | 24 octombrie 2021 12:02:23 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.66 kb |
#include <bits/stdc++.h>
using namespace std;
inline void Open(const string Name) {
#ifndef ONLINE_JUDGE
(void)!freopen((Name + ".in").c_str(), "r", stdin);
(void)!freopen((Name + ".out").c_str(), "w", stdout);
#endif
}
int N, l, r, m, q, ans;
int main() {
//Open("");
cin >> N;
l = 1, r = N;
while(l <= r) {
m = (l + r) / 2;
cout << "? " << m << "\n";
cout.flush();
cin >> q;
if(q == 0)
l = m + 1;
else {
ans = m;
r = m - 1;
}
}
cout << "? " << m << "\n";
cout.flush();
return 0;
}