#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, p, l, r, mid, found, x;
int main() {
//cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
l = 1;
r = n;
while (1) {
if (found) return cout << "= " << p << '\n', int(0);
mid = l+(r-l)/2;
cout << "? " << mid << '\n';
cin >> x;
if (x == -1) {
l = mid+1;
}
else if (x == 0) {
found = 1;
p = mid;
}
else {
r = mid-1;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |