#include <bits/stdc++.h>
using namespace std;
/*const int C = 4;
int prv = 0;
bool query( long long c ) {
cout << "? " << c << endl;
bool ans = (abs( prv - c ) >= C);
prv = c;
return ans;
}*/
bool query( long long c ) {
cout << "? " << c << endl;
bool ans;
cin >> ans;
return ans;
}
void answer( long long c ) {
cout << "= " << c << endl;
}
int main() {
long long n;
cin >> n;
query( n / 2 );
int l = n / 2, c = 0;
for ( int k = log2( n ); k >= 0; k-- ) {
if ( c + (1 << k) >= n )
continue;
if ( l > n / 2 ) {
l -= c + (1 << k);
if ( !query( l ) )
c += (1 << k);
} else {
l += c + (1 << k);
if ( !query( l ) )
c += (1 << k);
}
}
answer( c + 1 );
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |