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>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
int l=0,r=n;
vector<int> v;
while(r-l>1){
int m=(l+r)>>1;
v.push_back(m);
l=m;
}
bool flag=0;
int s=n;
int n1=v.size();
for(int i=n1-1;i>=0;i--){
if(flag==0){
s-=v[i];
}
else{
s+=v[i];
}
flag^=1;
}
cout<<"? "<<s<<endl;
int b=0;
cin>>b;
l=0,r=n;
while(r-l>1){
int m=(l+r)>>1;
if(flag==1){
s+=m;
}
else{
s-=m;
}
flag^=1;
cout<<"? "<<s<<endl;
int k;cin>>k;
if(k==1){
r=m;
}
else{
l=m;
}
}
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... |