aboutsummaryrefslogtreecommitdiff
path: root/12_interactive_problems/hidden_integer_3112.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--12_interactive_problems/hidden_integer_3112.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/12_interactive_problems/hidden_integer_3112.cpp b/12_interactive_problems/hidden_integer_3112.cpp
new file mode 100644
index 0000000..66e5a09
--- /dev/null
+++ b/12_interactive_problems/hidden_integer_3112.cpp
@@ -0,0 +1,16 @@
1#include <iostream>
2#include <string>
3
4int 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}

Generated with cgit - Back to sebastiano.tronto.net