/**
* author: chowgz
* created: 13/04/2021 20:13:22
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
long long n;
cin >> n;
long long l = 1, r = n - 1, m = (l + r) / 2;
stack<long long> s;
while (m != n - 1) {
m = (l + r) / 2;
s.push(m);
l = m + 1;
}
long long cur = n;
bool up = false;
while (!s.empty()) {
cur += up ? s.top() : -s.top();
up = !up;
s.pop();
}
bool yes;
auto ask = [&](long long x) {
cur += up ? x : -x;
up = !up;
cout << "? " << cur << endl;
cin >> yes;
};
cout << "? " << cur << endl;
cin >> yes;
l = 1;
r = n - 1;
m = (l + r) / 2;
long long ans = n;
while (l <= r) {
ask(m);
if (yes) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
m = (l + r) / 2;
}
cout << "= " << ans << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |