#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map <ll,bool> bio;
int main()
{
int n;
cin >> n;
int mx = 62;
ll ans = 0LL;
cout << "? 1\n";
bio[1]=true;
ll lastask = 1;
for(int i = mx; i >= 0; i--)
{
ll now = ans + (1LL<<i);
if(lastask-now > 1 && !bio[lastask-now])
{
cout << "? " << lastask-now << "\n";
int rez;
cin >> rez;
if(rez==1)
{
bio[lastask-now]=true;
lastask -= now;
continue;
}
else
{
bio[lastask-now]=true;
ans += (1LL<<i);
lastask -= now;
continue;
}
}
if(lastask+now <= n && !bio[lastask+now])
{
cout << "? " << lastask+now << "\n";
int rez;
cin >> rez;
lastask += now;
bio[lastask]=true;
if(rez==0)
{
ans += (1LL<<i);
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |