1266A.md (2493B)
1 Source: https://codeforces.com/problemset/problem/1266/A 2 3 A. Competitive Programmer 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 "Oh, I just spent $x_i$ hours solving problems", said the $i$-th of them. 24 25 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$. 26 27 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: 28 29 * rearranged its digits, or 30 * wrote a random number. 31 32 This way, Alice generated $n$ numbers, denoted $y_1$, ..., $y_n$. 33 34 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). 35 36 Input 37 38 The first line contains a single integer $n$ ($1 \leq n \leq 418$) — the number of grandmasters Bob asked. 39 40 Then $n$ lines follow, the $i$-th of which contains a single integer $y_i$ — the number that Alice wrote down. 41 42 Each of these numbers has between $2$ and $100$ digits '0' through '9'. They can contain leading zeroes. 43 44 Output 45 46 Output $n$ lines. 47 48 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". 49 50 Example 51 52 Input 53 54 ``` 55 6 56 603 57 006 58 205 59 228 60 1053 61 0000000000000000000000000000000000000000000000 62 ``` 63 64 Output 65 66 ``` 67 red 68 red 69 cyan 70 cyan 71 cyan 72 red 73 ``` 74 75 Note 76 77 In the first example, there is one rearrangement that yields a number divisible by $60$, and that is $360$. 78 79 In the second example, there are two solutions. One is $060$ and the second is $600$. 80 81 In the third example, there are $6$ possible rearrangments: $025$, $052$, $205$, $250$, $502$, $520$. None of these numbers is divisible by $60$. 82 83 In the fourth example, there are $3$ rearrangements: $228$, $282$, $822$. 84 85 In the fifth example, none of the $24$ rearrangements result in a number divisible by $60$. 86 87 In the sixth example, note that $000\dots0$ is a valid solution.