The meaning of problems
https://vjudge.net/problem/CodeForces-1260C
A string of bricks, usually a multiple of r multiples of b must be not painted red, all multiples of b rather than a multiple of r must be painted blue, are selected from a common multiple of the coating. After the painted brick elected, and asked whether there must be a continuous k-brick the same color.
Thinking
When r and b have a common factor (i.e. gcd! = 1), it can be found just skips some number, and no difference in its simplest form. So let's reduction, the reduction, if r == b, then definitely the solvability of (post questions Tu); otherwise, assume b> r, then the sequence must be similar xrbrbrrb, because faster growth b, then for a continuous period of r, we use two b to separate them, the number of positions between the two and b is b-1, k r to be occupied by a length of (k-1) * r + 1, is determined two b between the two can not be used to fill the k r, if or how the position, then not; otherwise feasible.
Code
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define ll long long const int N=200005; const int mod=1e9+7; const double eps=1e-8; const double PI = acos(-1.0); #define lowbit(x) (x&(-x)) ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } int main () { std::ios::sync_with_stdio(false); int t; cin>>t; while(t--) { ll r,b,k; cin>>r>>b>>k; if(r>b) swap(r,b); ll g=gcd(r,b); r/=g,b/=g; if(r==b) { cout<<"OBEY"<<endl; } else if(b-1<(k-1)*r+1) cout<<"OBEY"<<endl; else cout<<"REBEL"<<endl; } return 0; }