A13157 | Competitive Programmer
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked $n$ of them how much effort they needed to reach red.
"Oh, I just spent $x_i$ hours solving problems", said the $i$ -th of them.
Bob wants to train his math skills, so for each answer he wrote down the number of minutes ( $60 \cdot x_i$ ), thanked the grandmasters and went home. Bob could write numbers with leading zeroes — for example, if some grandmaster answered that he had spent $2$ hours, Bob could write $000120$ instead of $120$ .
Alice wanted to tease Bob and so she took the numbers Bob wrote down, and for each of them she did one of the following independently:
- rearranged its digits, or
- wrote a random number.
This way, Alice generated $n$ numbers, denoted $y_1$ , ..., $y_n$ .
For each of the numbers, help Bob determine whether $y_i$ can be a permutation of a number divisible by $60$ (possibly with leading zeroes).
"Oh, I just spent $x_i$ hours solving problems", said the $i$ -th of them.
Bob wants to train his math skills, so for each answer he wrote down the number of minutes ( $60 \cdot x_i$ ), thanked the grandmasters and went home. Bob could write numbers with leading zeroes — for example, if some grandmaster answered that he had spent $2$ hours, Bob could write $000120$ instead of $120$ .
Alice wanted to tease Bob and so she took the numbers Bob wrote down, and for each of them she did one of the following independently:
- rearranged its digits, or
- wrote a random number.
This way, Alice generated $n$ numbers, denoted $y_1$ , ..., $y_n$ .
For each of the numbers, help Bob determine whether $y_i$ can be a permutation of a number divisible by $60$ (possibly with leading zeroes).
输入格式
The first line contains a single integer $n$ ( $1 \leq n \leq 418$ ) — the number of grandmasters Bob asked.
Then $n$ lines follow, the $i$ -th of which contains a single integer $y_i$ — the number that Alice wrote down.
Each of these numbers has between $2$ and $100$ digits '0' through '9'. They can contain leading zeroes.
Then $n$ lines follow, the $i$ -th of which contains a single integer $y_i$ — the number that Alice wrote down.
Each of these numbers has between $2$ and $100$ digits '0' through '9'. They can contain leading zeroes.
输出格式
Output $n$ lines.
For each $i$ , output the following. If it is possible to rearrange the digits of $y_i$ such that the resulting number is divisible by $60$ , output "red" (quotes for clarity). Otherwise, output "cyan".
For each $i$ , output the following. If it is possible to rearrange the digits of $y_i$ such that the resulting number is divisible by $60$ , output "red" (quotes for clarity). Otherwise, output "cyan".
输入输出样例
输入 #1
6 603 006 205 228 1053 0000000000000000000000000000000000000000000000
输出 #1
red red cyan cyan cyan red
In the first example, there is one rearrangement that yields a number divisible by $60$ , and that is $360$ .
In the second example, there are two solutions. One is $060$ and the second is $600$ .
In the third example, there are $6$ possible rearrangments: $025$ , $052$ , $205$ , $250$ , $502$ , $520$ . None of these numbers is divisible by $60$ .
In the fourth example, there are $3$ rearrangements: $228$ , $282$ , $822$ .
In the fifth example, none of the $24$ rearrangements result in a number divisible by $60$ .
In the sixth example, note that $000\dots0$ is a valid solution.
In the second example, there are two solutions. One is $060$ and the second is $600$ .
In the third example, there are $6$ possible rearrangments: $025$ , $052$ , $205$ , $250$ , $502$ , $520$ . None of these numbers is divisible by $60$ .
In the fourth example, there are $3$ rearrangements: $228$ , $282$ , $822$ .
In the fifth example, none of the $24$ rearrangements result in a number divisible by $60$ .
In the sixth example, note that $000\dots0$ is a valid solution.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted