// No.246 質問と回答 // https://yukicoder.me/problems/no/246 // #include using namespace std; int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int ub = 1000000000; int lb = 1; while (ub > lb + 4) { int mid = (ub + lb) / 2; cout << "? " << mid << flush << endl; int res; cin >> res; if (res == 0) ub = mid; else lb = mid; } for (int i = lb; i <= ub+1; ++i) { cout << "? " << i << flush << endl; int res; cin >> res; if (res == 0) { cout << "! " << i - 1 << flush << endl; break; } } }