Cards

Time Limit: 2000MS

  Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit
Status

Description

Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions:

  • take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color;
  • take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color.

She repeats this process until there is only one card left. What are the possible colors for the final card?

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200) — the total number of cards.

The next line contains a string s of length
n — the colors of the cards.
s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively.

Output

Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order.

Sample Input

Input
2
RB
Output
G
Input
3
GRG
Output
BR
Input
5
BBBBB
Output
B

Sample Output

Hint

In the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.

In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and
a red card for a blue card, then exchange the blue card and remaining green card for a red card.

In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards.

Source


如果只有一种颜色,那么只可能生成一种颜色,如果有两种就要分情况了,如果两种颜色各一个,输出的也只能有一种颜色,,,,,,,,

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char str[10010];
int main()
{
int n;
cin>>n;
cin>>str;
int R,G,B;
R=B=G=0;
for(int i=0;i<n;i++)
{
if(str[i]=='R') R++;
if(str[i]=='G') G++;
if(str[i]=='B') B++;
}
if(R&&G==0&&B==0) cout<<"R"<<endl;
else if(R==0&&G&&B==0) cout<<"G"<<endl;
else if(R==0&&G==0&&B) cout<<"B"<<endl;
else if(R==1&&G==1&&B==0) cout<<"B"<<endl;
else if(R==1&&G==0&&B==1) cout<<"G"<<endl;
else if(R==0&&G==1&&B==1) cout<<"R"<<endl; else if(R==1&&G==0&&B>1) cout<<"GR"<<endl;
else if(R==1&&G>1&&B==0) cout<<"BR"<<endl;
else if(R==0&&G==1&&B>1) cout<<"GR"<<endl;
else if(R==0&&G>1&&B==1) cout<<"BR"<<endl;
else if(R>1&&G==1&&B==0) cout<<"BG"<<endl;
else if(R>1&&G==0&&B==1) cout<<"BG"<<endl; else cout<<"BGR"<<endl;
return 0;
}

Codeforces--626B--Cards(模拟)的更多相关文章

  1. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  2. CodeForces 626B Cards

    瞎搞题...凭直觉+猜测写了一发,居然AC了.. #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  3. Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列

    题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...

  4. Codeforces 389B(十字模拟)

    Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submi ...

  5. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  7. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  8. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  9. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

  10. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

随机推荐

  1. VC socket api使用引入

    1.在创建项目时勾上windows socket api的使用 2.头文件 #pragma  comment(lib,"WS2_32.lib") 3.初始化 WSADATA dat ...

  2. UVM基础之--------uvm_root

    uvm_root 是uvm的顶层实例扮演了一个top-level and phase controller 的作用,对于component来说.该类不需要用户实例化,他是一个自动实例化了的类,用户直接 ...

  3. vs for Mac中的启用Entity Framework Core .NET命令行工具

    在vs for Mac的工具菜单中已没有了Package Manager Console. 我们可以通过以下方法使用Entity Framework Core .NET命令行工具: 1.添加Nuget ...

  4. 批量注释LOG

    sed -i "s/LOG/\/\/ LOG/g" `grep LOG\(TRACE\) -rl .`

  5. UIResponder详解

    UIResponder Class Reference Managing the Responder Chain 1.- (UIResponder *)nextResponder 返回接收者的下一个相 ...

  6. AcDbTable 类

    Table 例子学习笔记在这个例子中,ARX向我们展示了ACDBTABLE类的一些基本操作方法,ACDBTABLE类是ACAD2005及其以后的产品,应该是说ACDBDATATABLE的升级产品,Ac ...

  7. CAD读取属性块

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  8. 零基础转行Linux云计算运维工程师获得20万年薪的超级学习技巧

    云计算概念一旦产生便一发不可收拾,成为移动互联网时代最为火热的行业之一.国内各大互联网公司例如阿里.腾讯.百度.网易等纷纷推出自己的云计算产品,3月10日,腾讯云0.01元投标时间更是让云计算在普罗大 ...

  9. jdk8--collect总结

    https://blog.csdn.net/u014351782/article/details/53818430 一,collect是一个终端操作,它接收的参数是将流中的元素累积到汇总结果的各种方式 ...

  10. hdu2015 偶数求和【C++】

    偶数求和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...