hidden_integer_3112.cpp (271B)
1 #include <iostream> 2 #include <string> 3 4 int main() { 5 int m, l{0}, r{1000000000}; 6 std::string s; 7 while (l+1 != r) { 8 m = (l+r)/2; 9 std::cout << "? " << m << std::endl; 10 std::cin >> s; 11 if (s == "YES") l = m; 12 else r = m; 13 } 14 15 std::cout << "! " << r << std::endl; 16 }