#include using namespace std; int main() { int L = 1, R = 1000000; long long prev = 1; cout << "? " << prev << endl; cout.flush(); while (L < R) { int mid = (L + R) / 2; // 判定したいこと: // a >= mid + 1 かどうか // // |a - prev| >= |a - x| が成り立つ境界を // (prev + x) / 2 = mid + 0.5 // にしたいので、 // x = 2 * mid + 1 - prev long long x = 2LL * mid + 1 - prev; cout << "? " << x << endl; cout.flush(); int res; cin >> res; if (res == -1) return 0; if (res == 1) { // |a-prev| >= |a-x| // つまり a >= mid + 1 L = mid + 1; } else { // a <= mid R = mid; } prev = x; } cout << "! " << L << endl; cout.flush(); return 0; }