This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
ll logll(ll x) {
for (ll logx = 0; ; (x >>= 1) && (logx++)) if (x == 0) return logx;
}
bool ask(ll p) {
cout << "? " << p << endl;
bool answ;
cin >> answ;
return answ;
}
ll N;
ll lower = 0;
ll upper;
ll P = 1;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
upper = 2 << logll(N - 1);
ask(1);
while (lower + 1 < upper) {
ll mid = (upper + lower) / 2;
if (2 * P > N) P -= mid;
else P += mid;
if (ask(P)) {
upper = mid;
} else {
lower = mid;
}
}
cout << "= " << upper << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |