fork download
  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define mp make_pair
  5. #define pb push_back
  6. #define all(v) v.begin(), v.end()
  7.  
  8. using namespace std;
  9. typedef long long LL;
  10. const LL MOD = 1e9 + 7;
  11.  
  12. int main() {
  13. int A, B;
  14. cin >> A >> B;
  15. while (A <= B) {
  16. int mid = (A + B) / 2;
  17. cout << mid << endl;
  18. string s;
  19. cin >> s;
  20. if (s == "selamat") break;
  21. else {
  22. cin >> s;
  23. if (s == "besar") B = mid - 1;
  24. else A = mid + 1;
  25. }
  26. }
  27. }
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
-172879549
-86434284
-43211651
-21600335
-10794677
-5391848
-2690433
-1339726
-664372
-326695
-157857
-73438
-31228
-10123
429
5705
8343
9662
10321
10651
10816
10898
10939
10960
10970
10975
10978
10979
10980