#include <bits/stdc++.h>
using namespace std;
int ask(int q){
cout << "? " << q << endl;
int ans;
cin >> ans;
return ans;
}
int solve(int n, int c, int add){
if(n == 1)
return 1 + add;
int diff = n/2 + add;
int q = (c - diff > 0)?c-diff:c+diff;
if(ask(q))
return solve(n/2, q, add);
else
return solve(n/2, q, add + n/2);
}
int main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
int n;
cin >> n;
ask(n/3);
int ans = solve(n, n/3, 0);
cout << "= " << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (3 queries) |
2 |
Incorrect |
0 ms |
344 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (3 queries) |
2 |
Incorrect |
0 ms |
344 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (3 queries) |
2 |
Incorrect |
0 ms |
344 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (3 queries) |
2 |
Incorrect |
0 ms |
344 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (3 queries) |
2 |
Incorrect |
0 ms |
344 KB |
Wrong guess |
3 |
Halted |
0 ms |
0 KB |
- |