#include <bits/stdc++.h>
using namespace std;
int32_t main(){
//ios::sync_with_stdio(0);
//cin.tie(0);
long long n;
cin >> n;
long long cur=1,smol=1,big=1;
long long lo=1,hi=n,mid;
while(lo<hi){
mid=(lo+hi)/2ll;
if(cur>1) cur-=mid;
else cur+=mid;
lo=mid+1;
smol=min(smol,cur);
big=max(big,cur);
}
cur=2-smol;
//cout << smol << ' ' << big << '\n';
lo=1,hi=n;
cout << "? " << cur << endl;
int x;
cin >> x;
long long dir=1;
bool prev=true;
while(lo<hi){
if(prev||lo==hi-1ll) mid=(lo+hi)/2ll;
else mid=(lo+hi+1ll)/2ll;
cur+=mid*dir;
dir*=-1ll;
cout << "? " << cur << endl;
cin >> x;
if(x) hi=mid,prev=false;
else lo=mid+1ll,prev=true;
}
cout << "= " << lo << endl;
}
# | 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... |