题意:
给出一串数字,数字的顺序可以随意变换,如果有一种情况可以是该数字能够整除60,那么输出red;否则输出cyan
思路:
60=2 * 2 * 5 * 3 = 10 * 2 * 3。
所以如果要想输出red,就要满足下面三个条件:
1 序列必须存在0
2 序列所有数字之和必须是3的倍数
3 序列在只有一个0的情况下,必须有2的倍数存在
代码:
#include<bits/stdc++.h>
using namespace std;
map<int , int>v;
int n;
string s;
void solve()
{
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)
{
cout << "cyan" << endl;
}
else if(v[0]==0)
{
cout << "cyan" << endl;
}
else if(v[0]==1)
{
for(int i = 1 ; i < 5 ; i++)
{
if(v[i*2]>=1)
{
cout << "red" << endl;
return ;
}
}
cout << "cyan" << endl;
return ;
}
else
{
cout << "red" << endl;
return ;
}
}
int main()
{
cin >> n;
while(n--)
{
solve();
}
return 0;
}