SHARE
TWEET

Untitled

a guest May 26th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int l, r;
  4.  
  5. using namespace std;
  6.  
  7. bool req(int a){
  8.     cout << "? " << a << endl;
  9.     string s;
  10.     cin >> s;
  11.     return (s == "<");
  12. }
  13.  
  14. int bs(){
  15.     int m = (l + r) / 2;
  16.     if (req(m))
  17.         l = m;
  18.     else
  19.         r = m;
  20. }
  21.  
  22. int main()
  23. {
  24.     int n;
  25.     cin >> n;
  26.     l = 1;
  27.     r = n;
  28.     while (r != l + 1)
  29.         bs();
  30.     cout << "! " << r;
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top