#include #define MIN 1 #define MAX 1000000000 int Center(int lower, int higher) { higher -= lower; higher /= 2; return lower + higher; } int main() { int min = MIN; int max = MAX; int in; for(int i = 0; i < 99; i++) { int c = Center(min, max); std::cout << "? " << c << std::endl; std::cout << std::flush; std::cin >> in; (in == 1)? min = c : max = c - 1; if ((max - min) <= 1) break; } std::cout << "? " << max << std::endl; std::cout << std::flush; std::cin >> in; int ans = (in == 0)? min : max; std::cout << "! " << ans << std::endl; return 0; }