#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool ask(ll p) {
cout << "? " << p << endl;
bool ans;
cin >> ans;
return ans;
}
int main() {
ll n;
cin >> n;
ll l = 0, r = n + 1;
ll prev = 1;
ask(1);
while (1 < r - l) {
ll mid = (l + r) / 2;
ll next = prev + mid;
if (0 < prev - mid)
next = prev - mid;
else if (n < next) {
if (prev == 1) {
r = n;
break;
}
prev = 1;
ask(prev);
continue;
}
if (ask(next))
r = mid;
else
l = mid;
prev = next;
}
cout << "= " << r << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |