#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
#define pb push_back
typedef long long ll;
const ll inf=1e18;
ll qry(ll tar){
cout<<"? "<<tar<<endl;
ll re;
cin>>re;
return re;
}
void solve(){
ll n;
cin>>n;
ll x=0;
ll pos=1;
ll lef=1, rig=n-1;
ll mx=-inf, mn=inf;
while(lef<=rig){
ll mid=(lef+rig)/2;
x+=pos*mid;
mx=max(mx, x);
mn=min(mn, x);
pos*=-1;
lef=mid+1;
}
// cout<<mn<<' '<<mx<<endl;
ll cur=1-mn;
lef=1;
rig=n-1;
ll good=-1;
qry(cur);
pos=1;
while(lef<=rig){
ll mid=(lef+rig)/2;
cur+=pos*mid;
pos*=-1;
if(qry(cur)){
good=mid;
rig=mid-1;
}
else{
lef=mid+1;
}
}
if(good==-1) cout<<"= "<<n<<endl;
else cout<<"= "<<good<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
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... |