#include <bits/stdc++.h>
using namespace std;
void solve(long long int left, long long int right) {
if(left >= right) {
cout << "=" << " " << left << endl;
return;
}
long long int mid = (left + right + 1) / 2;
cout << "?" << " " << mid << endl;
long long int ans;
cin >> ans;
if(ans == 1) {
solve(left, mid);
} else {
solve(mid + 1, right);
}
}
int main() {
//your code goes here
long long int n;
cin >> n;
solve(1, n);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (2 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Hair color 25 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (2 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Hair color 25 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (2 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Hair color 25 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (2 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Hair color 25 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (2 queries) |
2 |
Incorrect |
0 ms |
208 KB |
Hair color 25 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |