#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> save;
long long low = 1, high = n;
while (low < high) {
long long mid = (low + high) >> 1;
save.push_back(mid);
low = mid + 1;
}
long long pos = n;
while (save.size() > 0) {
long long x = save.back();
if (pos - x < 0) pos += x;
else pos -= x;
save.pop_back();
}
cout << "? " << pos << endl;
int trolley;
cin >> trolley;
low = 1, high = n;
while (low < high) {
long long mid = (low + high) >> 1;
long long L = pos - 1, R = n - pos;
if (L < mid) pos += mid;
else pos -= mid;
cout << "? " << pos << endl;
int res;
cin >> res;
if (res) high = mid;
else low = mid + 1;
}
cout << "= " << low;
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... |