Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. char ans;
  5. void ask(int x, int y) {
  6. cout << "? " << x << " " << y << endl;
  7. cin >> ans;
  8. }
  9.  
  10. int main() {
  11. string s;
  12. cin >> s;
  13. while (s != "end") {
  14. int curp = 1, prp = 0;
  15.  
  16. ask(0, curp);
  17. while (ans == 'y') {
  18. prp = curp;
  19. curp *= 2;
  20. ask(prp, curp);
  21. }
  22.  
  23. int L = prp, R = curp;
  24. while (R - L > 1) {
  25. int MID = L + R >> 1;
  26.  
  27. ask(L, MID);
  28.  
  29. if (ans == 'x')
  30. R = MID;
  31. else
  32. L = MID;
  33. }
  34.  
  35. cout << "! " << R << endl;
  36.  
  37. cin >> s;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement