summaryrefslogtreecommitdiffstats
path: root/problems/bs/bs.cpp
blob: 37600e6e61c2c0c25e223c5db3705a7b11108b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}