diff options
Diffstat (limited to 'problems/bs/bs.cpp')
-rw-r--r-- | problems/bs/bs.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/problems/bs/bs.cpp b/problems/bs/bs.cpp new file mode 100644 index 0000000..37600e6 --- /dev/null +++ b/problems/bs/bs.cpp @@ -0,0 +1,28 @@ +#include <iostream> + +using namespace std; + +int main() +{ + //cerr << "chert" << endl; + long long max; cin >> max; + + long long s = 0, e = max + 1; + + while (e - s > 1) + { + long long m = (e + s) / 2; + cout << m << endl; + string res; + cin >> res; + //cerr << "responce to " << m << " is " << res << endl; + if (res == "correct") + break; + else if (res == "high") + e = m; + else + s = m; + } + + return 0; +} |