#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;
while(l<r)
{
int mid=(l+r)/2;
if(a==mid){mid--;l--;}
if(a<mid)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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |