Cod sursa(job #2787891)
Utilizator | Data | 24 octombrie 2021 12:03:21 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.67 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 << "! " << ans << "\n";
cout.flush();
return 0;
}