Tutorial: 关键是满足条件, 我原来是考虑
m
i
n
(
r
,
b
)
∗
k
<
m
a
x
(
r
,
b
)
min(r, b)*k < max(r, b)
min(r,b)∗k<max(r,b)这样考虑是不全的, 考虑这样一组样例: 2 5 3 ,染序列
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
0,1,2,3,4,5,6,7,8,9,10, 其中
0
,
5
,
10
0, 5, 10
0,5,10被5标记,
2
,
4
,
6
,
8
2, 4, 6, 8
2,4,6,8被2标记, 一种贪心的策略就是找到一个位置pos被5标记, pos+1被2标记, 考虑pos-pos+5这个区间, 如果这个区间正好出现3个,那么有len = 2*(k-1)+1, 即区间长度肯定要大于该值则有(k - 1) * r + 1 < b, 再考虑另一种样例, 4 2 3, 显然,这种样例找不到所定义的pos位置, 可予以考虑同时将r,b 除去公因子, 最后再判断一下极端情况int是否会溢出
#include<bits/stdc++.h>usingnamespace std;#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)#define _rev(i, a, b) for (int i = (a); i >= (b); --i)#define _for(i, a, b) for (int i = (a); i < (b); ++i)#define _rof(i, a, b) for (int i = (a); i > (b); --i)#define oo 0x3f3f3f3f#define ll long long#define db double#define eps 1e-8#define bin(x) cout << bitset<10>(x) << endl;#define what_is(x) cerr << #x << " is " << x << endl#define met(a, b) memset(a, b, sizeof(a))#define all(x) x.begin(), x.end()#define pii pair<int, int>intnxt(){int ret;scanf("%d",&ret);return ret;}constint maxn =2e5+10;signedmain(){int n =nxt();while(n--){
ll r =nxt(), b =nxt(), k =nxt();
ll g =__gcd(r, b);
r /= g, b /= g;if(r > b)swap(r, b);if((k -1)* r +1< b)
cout <<"REBEL"<< endl;else
cout <<"OBEY"<< endl;}}