Advertisement
Ashot_27

Untitled

Nov 27th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define int long long
  4.  
  5. using namespace std;
  6.  
  7. int gcd(int a, int b) {
  8. int res = 1;
  9. if (!a) return b;
  10. if (!b) return a;
  11. while (!(a % 2) && !(b % 2))
  12. { res *= 2; b /= 2; a /= 2; }
  13. while (!(a % 2))
  14. a /= 2;
  15. while (!(b % 2))
  16. b /= 2;
  17. if (a > b) {int t = a; a = b; b = t;}
  18. return res * gcd(a, b - a);}
  19.  
  20.  
  21. int32_t main() {
  22. int t; cin >> t;
  23. while (t--) {
  24. int r, b, k; cin >> r >> b >> k;
  25. if (r > b) { int t = r; r = b; b = t;}
  26. if ((b - 1 - gcd(b, r)) / r + 1 >= k)
  27. cout << "REBEL\n";
  28. else
  29. cout << "OBEY\n"; }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement