Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int l, r;
- using namespace std;
- bool req(int a){
- cout << "? " << a << endl;
- string s;
- cin >> s;
- return (s == "<");
- }
- int bs(){
- int m = (l + r) / 2;
- if (req(m))
- l = m;
- else
- r = m;
- }
- int main()
- {
- int n;
- cin >> n;
- l = 1;
- r = n;
- while (r != l + 1)
- bs();
- cout << "! " << r;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement