#include int q(int x) { int ret; std::cout << "? " << x << std::endl; std::cout << std::flush; std::cin >> ret; return ret; } int main() { int a; a = q(100); if(a == 0) { std::cout << "! 100" << std::endl; return 0; } int min, max, cur, i; min = 1; max = (a > 0)? 1000000000:100; cur = (max - min) / 2; i = 1; int p = 100, pp = -1; for(; i < 100; i++) { a = q(cur); if(a == 0) break; pp = p; p = cur; if(a > 0) { min = cur + 1; cur += ((max - min) / 2); } else { max = cur - 1; cur -= ((max - min) / 2) - 1; } if(cur == (p - 1) && cur == (pp - 2)) cur++; max--; min--; } std::cout << "! " << cur + i << std::endl; return 0; }