• C. Infinite Fence


    You are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor.

    You must paint a fence which consists of 1010010100 planks in two colors in the following way (suppose planks are numbered from left to right from 00):

    • if the index of the plank is divisible by rr (such planks have indices 00, rr, 2r2r and so on) then you must paint it red;
    • if the index of the plank is divisible by bb (such planks have indices 00, bb, 2b2b and so on) then you must paint it blue;
    • if the index is divisible both by rr and byou can choose the color to paint the plank;
    • otherwise, you don't need to paint the plank at all (and it is forbidden to spent paint on it).

    Furthermore, the Government added one additional restriction to make your punishment worse. Let's list all painted planks of the fence in ascending order: if there are kk consecutive planks with the same color in this list, then the Government will state that you failed the labor and execute you immediately. If you don't paint the fence according to the four aforementioned conditions, you will also be executed.

    The question is: will you be able to accomplish the labor (the time is not important) or the execution is unavoidable and you need to escape at all costs.

    Input

    The first line contains single integer TT (1T10001≤T≤1000) — the number of test cases.

    The next TT lines contain descriptions of test cases — one per line. Each test case contains three integers rr, bb, kk (1r,b1091≤r,b≤109, 2k1092≤k≤109) — the corresponding coefficients.

    Output

    Print TT words — one per line. For each test case print REBEL (case insensitive) if the execution is unavoidable or OBEY (case insensitive) otherwise.

    Example
    input
    Copy
    4
    1 1 2
    2 10 4
    5 2 3
    3 2 2
    
    output
    Copy
    OBEY
    REBEL
    OBEY
    OBEY
    
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <set>
    #include <queue>
    #include <map>
    #include <sstream>
    #include <cstdio>
    #include <cstring>
    #include <numeric>
    #include <cmath>
    #include <iomanip>
    #include <deque>
    #include <bitset>
    #define ll              long long
    #define PII             pair<int, int>
    #define rep(i,a,b)      for(int  i=a;i<=b;i++)
    #define dec(i,a,b)      for(int  i=a;i>=b;i--)
    using namespace std;
    int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
    const long long INF = 0x7f7f7f7f7f7f7f7f;
    const int inf = 0x3f3f3f3f;
    const double pi = 3.14159265358979323846;
    const double eps = 1e-6;
    const int mod = 998244353;
    const int N = 2500 + 5;
    //if(x<0 || x>=r || y<0 || y>=c)
    
    inline ll read()
    {
        ll x = 0; bool f = true; char c = getchar();
        while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
        while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
        return f ? x : -x;
    }
    int qpow(int m, int k, int mod)
    {
        int res = 1, t = m;
        while (k)
        {
            if (k & 1)
                res = res * t % mod;
            t = t * t % mod;
            k >>= 1;
        }
        return res;
    }
    ll gcd(ll m, ll n)
    {
        return n == 0 ? m : gcd(n, m % n);
    }
    ll lcm(ll m, ll n)
    {
        return m * n / gcd(m, n);
    }
    int main()
    {
        int T;
        cin >> T;
        while(T--)
        {
            ll r, b, k;
            cin >> r >> b >> k;
            if (b < r)
                swap(r, b);
            if((b-1-gcd(r,b))/r+1<k)
                cout<<"OBEY"<<endl;
            else
                cout << "REBEL" << endl;
        }
        return 0;
    }
     
  • 相关阅读:
    linux下如何解压和压缩文件
    windows如何查看jdk的安装目录
    java.sql.SQLException: Data truncated for column 'seat_number' at row 1
    Error:(23, 0) Could not find method implementation() for arguments [directory 'libs'] on object of t
    grandle Project sync failed.please fix your project and try again
    java如何实现批量删除pdf指定的页数
    Java实现批量将word文档转换成PDF
    Linux下查看目录文件数和文件大小
    IDEA启动Springboot时,解决报错java.lang.NoClassDefFoundError: javax/servlet/Filter
    如何SpringBoot项目改为外置Tomcat启动
  • 原文地址:https://www.cnblogs.com/dealer/p/13028592.html
Copyright © 2020-2023  润新知