zoukankan      html  css  js  c++  java
  • 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;
    }
     
  • 相关阅读:
    杜教筛
    GCD Counting Codeforces
    洛谷 P4317 花神的数论题 || bzoj3209
    About set HDU
    Queue Sequence HDU
    bzoj2154||洛谷P1829 Crash的数字表格&&JZPTAB && bzoj3309 DZY Loves Math
    洛谷 P1445 [Violet]樱花
    洛谷 P2158 [SDOI2008]仪仗队 && 洛谷 P1447 [NOI2010]能量采集
    nginx中使用waf防火墙
    wordpress安装
  • 原文地址:https://www.cnblogs.com/dealer/p/13028592.html
Copyright © 2011-2022 走看看