A. Competitive Programmer ----- thinking (routine title)

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 xi 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⋅xi), 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 y1, …, yn.

For each of the numbers, help Bob determine whether yi can be a permutation of a number divisible by 60 (possibly with leading zeroes).

Input
The first line contains a single integer n (1≤n≤418) — the number of grandmasters Bob asked.

Then n lines follow, the i-th of which contains a single integer yi — 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
Output n lines.

For each i, output the following. If it is possible to rearrange the digits of yi such that the resulting number is divisible by 60, output “red” (quotes for clarity). Otherwise, output “cyan”.

Example
inputCopy

6
603
006
205
228
1053
0000000000000000000000000000000000000000000000
outputCopy
red
red
cyan
cyan
cyan
red
Note
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…0 is a valid solution.

Meaning of the questions: to give you a sequence, the sequence can be arranged randomly so that is a multiple of 60, the output red, otherwise the output cyan.

Analysis: factorization 60 = 2 * 2 * 5 * 3 * 2 * 3 = 10.
Sequence 10 that must be present 0
3 that all figures and sequence must be a multiple of 3.
2 sequence found only in the case of a 0, there must be a multiple of 2 in the presence of


#include<bits/stdc++.h>
using namespace std;
map<int,int> v;
int n;
string s;
void slove()
{
	cin>>s;v.clear();
	int sum=0;
	for(int i=0;i<s.size();i++)
	{
		v[s[i]-'0']++;
		sum=sum+s[i]-'0';
	}
	if(sum%3!=0)
	{
		puts("cyan");
		return ;
	}
	if(v[0]==0)
	{
		puts("cyan");
		return ;
	}
	else if(v[0]==1)
	{
		for(int i=1;i<5;i++) 
		{
			if(v[i*2]>=1)
			{
				puts("red");
				return ;
			}
		}
		puts("cyan");
		return ;
	}
	puts("red");
	return ;
}
int main()
{
	cin>>n;
	while(n--) slove();
 } 


Published 309 original articles · won praise 6 · views 5247

Guess you like

Origin blog.csdn.net/qq_43690454/article/details/104086641