This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
int l=1,r=n;
int x;
if(n==2)
{
cout<<"? 1"<<endl;
cin>>x;
cout<<"? 2"<<endl;
cin>>x;
if(x==0)cout<<"= 2"<<endl;
else cout<<"= 1"<<endl;
return 0;
}
int a,b;
a=(1+n/2+1)/2;
cout<<"? "<<a<<endl;
cin>>x;
int y=1;
while(l<r)
{
if(y==min(n,64ll))break;
y++;
int mid=(l+r)/2;
//if(a==mid){mid--;l--;}
if(a+mid<=n)b=a+mid;
else b=a-mid;
a=b;
cout<<"? "<<b<<endl;
cin>>x;
if(x==0)
{
l=mid+1;
}
else
{
r=mid;
}
}
if(x==1)cout<<"= "<<l<<endl;
else cout<<"= "<<r<<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... |