-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1_Guess_the_Number.cpp
More file actions
44 lines (39 loc) · 1.14 KB
/
1_Guess_the_Number.cpp
File metadata and controls
44 lines (39 loc) · 1.14 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
//----------------------------------------------------------------//
// definitions //
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
// #define endl '\n'
//----------------------------------------------------------------//
// preDefined functions//
//----------------------------------------------------------------//
//data types//
//----------------------------------------------------------------//
// helper functions //
//----------------------------------------------------------------//
// solve function//
void solve() {
unsigned long long high = 1000000, low = 0, mid;
while (high - low > 0) {
mid = (high + low + 1) >> 1;
cout << mid << endl;
string str;
cin >> str;
if (str == ">=")low = mid;
else high = mid-1;
}
cout << "! " << low << endl;
}
//----------------------------------------------------------------//
// main function//
int main() {
ios_base::sync_with_stdio( false );
cin.tie( NULL );
cout.tie( NULL );
long long test = 1;
// cin >> test;
while (test--) {
solve();
}
}