#include<bits/stdc++.h>
using namespace std;
long long n, a, b, m, prv, ans;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n;
prv=1;
cout<<"? "<<prv<<endl;
cin>>ans;
a=1;b=n;
while(a<b)
{
m=(a+b)/2;
if(prv-m<1&&prv+m>n)
{
cout<<"? 1"<<endl;
cin>>ans;
prv=1;
}
if(prv-m>=1)
{
prv-=m;
cout<<"? "<<prv<<endl;
cin>>ans;
if(ans==1)b=m;
else a=m+1;
}
else
{
prv+=m;
cout<<"? "<<prv<<endl;
cin>>ans;
if(ans==1)b=m;
else a=m+1;
}
}
cout<<a<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |