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 sf scanf
#define pf printf
#define pb push_back
typedef long long ll;
int ask(ll x){
cout<<"? "<<x<<endl;
fflush(stdout);
int a;cin>>a;
return a;
}
void ans(ll x){
cout<<"= "<<x<<endl;
exit(0);
}
int main(){
ll n;cin>>n;
ll lo=1,hi=n-1,mid,res=n;
vector<ll> v;
while(lo<=hi){
mid=(lo+hi)>>1;
v.pb(mid);
lo=mid+1;
}
ll cur=1;int m=1;
for(int i=v.size()-1;i>=0;--i){
cur+=m*v[i];
m=-m;
}
ask(cur);
lo=1,hi=n-1;
while(lo<=hi){
mid=(lo+hi)>>1;
cur+=m*mid;
m=-m;
if(ask(cur)==1)res=mid,hi=mid-1;
else lo=mid+1;
}
ans(res);
}
# | 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... |