#include <bits/stdc++.h>
using namespace std;
long long n,maxi,i;
int query (int x){
int ans;
cout<<"? "<<x<<endl;
cin>>ans;
return ans;
}
void answer (int x){
cout<<"= "<<x<<endl;
}
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n;
for (maxi=0;;maxi++)
if ((1LL<<maxi) > n)
break;
maxi--;
long long sum = 0, sum2 = 0;
for (i=maxi;i>=0;i-=2)
sum += (1LL<<i);
for (i=maxi-1;i>=0;i-=2)
sum2 += (1LL<<i);
long long x = n - sum, c = 0;
query (x);
for (i=maxi;i>=0;i--){
if ((maxi - i) % 2){ /// ma duc in stanga
int ans = query (x - c - (1LL<<i));
x -= c + (1LL<<i);
if (!ans)
c += (1LL<<i);
} else { /// ma duc in dreapta
int ans = query (x + c + (1LL<<i));
x += c + (1LL<<i);
if (!ans)
c += (1L<<i);
}
}
answer(c+1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |