传送门
文章目录
- 题意:
- 思路:
题意:
思路:
碰到这样的题肯定是先写几个找找规律了,随便写几个就可以发现是以lcm(a,b)lcm(a,b)lcm(a,b)为一个循环,所以我们只需要在一个周期lcm(a,b)lcm(a,b)lcm(a,b)中求最长的一个跟kkk比较即可。
我们假设a<ba<ba<b,aaa涂蓝色,bbb涂红色,那么一个周期中蓝色个数为x=bgcd(a,b)x=\frac{b}{gcd(a,b)}x=gcd(a,b)b,红色个数为y=agcd(a,b)y=\frac{a}{gcd(a,b)}y=gcd(a,b)a,由于我们在lcm(a,b)lcm(a,b)lcm(a,b)的位置肯定是填红色更优,所以蓝色个数为x=bgcd(a,b)−1x=\frac{b}{gcd(a,b)}-1x=gcd(a,b)b−1,现在问题转化成了在yyy个抽屉里,平均的放入xxx个,求放的个数最多的抽屉。这个时候答案就比较显然,即cnt=x/y+(xmody!=0)cnt=x/y+(x\bmod y!=0)cnt=x/y+(xmody!=0),再跟kkk比较大小即可。
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;LL a,b,k;int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);int _; scanf("%d",&_);while(_--){scanf("%lld%lld%lld",&a,&b,&k);if(a>b) swap(a,b);LL x=b/__gcd(a,b)-1,y=a/__gcd(a,b);LL cnt=x/y+(x%y!=0);if(cnt>=k) puts("REBEL");else puts("OBEY");}return 0;
}
/**/