Pagini recente » Cod sursa (job #1075481) | Cod sursa (job #12313) | Cod sursa (job #2387478) | Cod sursa (job #542804) | Cod sursa (job #2887251)
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 69
#define nl(...) 42
#endif
#define ll long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll st, ll dr) {
assert(st <= dr);
return st + rng() % (dr - st + 1);
}
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int ask(int x) {
cout << "? " << x << endl;
int p;
cin >> p;
return p;
}
void solve(int test, istream &cin, ostream &cout) {
int n;
cin >> n;
int st = 1;
int dr = n;
while (st <= dr) {
int mid = st + (dr - st) / 2;
int q = ask(mid);
if (q == 1) {
st = mid + 1;
} else {
dr = mid - 1;
}
}
cout << "! " << dr << endl;
}
int main() {
// ifstream cin("tst.in");
// ofstream cout("tst.out");
ios_base::sync_with_stdio(0);
cin.tie(NULL);
auto start = std::chrono::high_resolution_clock::now();
bool multiTest = false;
int t;
if (multiTest) {
cin >> t;
} else {
t = 1;
}
for (int test = 1; test <= t; test++) {
solve(test, cin, cout);
}
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
// cerr << fixed << setprecision(6) << "Running time: " << (double) duration.count() / 1e6 << " seconds" << '\n';
return 0;
}