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 ll long long
ll n, tmp;
int query(ll x)
{
cout<<"? "<<x<<endl;
cin>>tmp;
return tmp;
}
int main()
{
cin>>n;
ll dir=1, st=1, cur=1, l=1, r=n;
while (l<r)
{
ll md=(l+r)/2;
if (cur+dir*md>=1) cur+=dir*md;
else st+=1-(cur+dir*md), cur=1;
l=md+1;
dir=-dir;
}
query(st);
cur=st, dir=1, l=1, r=n;
while (l<r)
{
ll md=(l+r)/2;
cur+=dir*md;
if (query(cur)) r=md;
else l=md+1;
dir=-dir;
}
cout<<"= "<<l<<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... |