#include <bits/stdc++.h>
using namespace std;
#define int long long
int l, r, ans, c;
void query(int x)
{
cout<<"? "<<x<<endl;
cin>>ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
l=max(1LL, n/3), r=l;
query(l);
int t=1;
for(int i=31; i>=0; i--)
{
int pf=0;
if((1LL<<i)+r<=n)
{
r+=(1LL<<i);
query(r);
if(ans==1)
{
pf=1;
l+=min(r-l, 1LL<<i);
}
t++;
}
if(l-(1LL<<i)>0LL&&pf==0)
{
l-=(1LL<<i);
query(l);
if(ans==1)
{
r-=min(r-l, (1LL<<i));
}
t++;
}
}
cout<<"= "<<abs(l-r)+1<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (5 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |