CF1260C.Infinite Fence
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 10100 planks in two colors in the following way (suppose planks are numbered from left to right from 0):
- if the index of the plank is divisible by r (such planks have indices 0, r, 2r and so on) then you must paint it red;
- if the index of the plank is divisible by b (such planks have indices 0, b, 2b and so on) then you must paint it blue;
- if the index is divisible both by r and b you 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 k 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.
你是一名反抗军领袖,正计划在你的国家发动一场革命。但邪恶的政府发现了你的计划,并以强制劳动的形式对你施以惩罚。
你必须用两种颜色粉刷一道由 10100 块木板组成的栅栏,粉刷规则如下(假设木板从左到右编号,起始编号为 0):
- 若某块木板的编号能被 r 整除(即该木板编号为 0、r、2r、…),则你必须将其涂成红色;
- 若某块木板的编号能被 b 整除(即该木板编号为 0、b、2b、…),则你必须将其涂成蓝色;
- 若某块木板的编号同时能被 r 和 b 整除,则你可以任选红色或蓝色为其上色;
- 其余所有木板均无需粉刷(且严禁对其使用颜料)。
此外,政府还额外增加了一条限制,以使你的惩罚更加严酷。我们将栅栏中所有已粉刷的木板按编号升序列出:若该序列中存在连续 k 块同色的木板,则政府将判定你未能完成劳动任务,并立即处决你。如果你未严格遵守上述四条规则进行粉刷,同样会被立即处决。
问题在于:你能否成功完成这项劳动(时间长短无关紧要),抑或处决不可避免,你必须不惜一切代价立刻逃亡?
输入格式
The first line contains single integer T (1≤T≤1000) — the number of test cases.
The next T lines contain descriptions of test cases — one per line. Each test case contains three integers r, b, k (1≤r,b≤109, 2≤k≤109) — the corresponding coefficients.
第一行包含一个整数 T(1≤T≤1000)—— 表示测试用例的数量。
接下来的 T 行每行描述一个测试用例。每个测试用例包含三个整数 r、b、k(1≤r,b≤109,2≤k≤109)—— 即对应的系数。
输出格式
Print T words — one per line. For each test case print REBEL (case insensitive) if the execution is unavoidable or OBEY (case insensitive) otherwise.
输出 T 个单词,每个单词占一行。对于每个测试用例,如果执行不可避免,则输出 REBEL(不区分大小写);否则输出 OBEY(不区分大小写)。
输入输出样例
输入#1
4 1 1 2 2 10 4 5 2 3 3 2 2
输出#1
OBEY REBEL OBEY OBEY
输入解题思路,AI测评打分。不知道怎么写?