#include #define MIN 1 #define MAX 1000000000 int Center(int lower, int higher) { higher += higher % 2; higher -= lower; higher /= 2; return lower + higher; } int main() { int min = MIN; int max = MAX; int in; for(int i = 0; i < 100; 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 (min == max) break; } std::cout << min; }