题意:

两张相同可以合并成相同;

两张不同可以产生另外一个不同;

求最终的可能颜色;

思路:

模拟啊。

总共也就那么几种情况,具体看挫code…….

#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define eps 1e-8
typedef __int64 LL; char s[220]; int num[4];
char temp[4]; int main()
{
int n;
scanf("%d",&n);
scanf("%s",s);
memset(num,0,sizeof(num));
temp[1]='B';temp[2]='G';temp[3]='R';
for(int i=0;i<n;i++)
{
if(s[i]=='B') num[1]++;
if(s[i]=='G') num[2]++;
if(s[i]=='R') num[3]++;
}
int x=0;
for(int i=1;i<=3;i++)
{
if(!num[i])
x++;
}
if(x==2)//有两个0;
{
for(int i=1;i<=3;i++)
if(num[i])
printf("%c",temp[i]);
return 0;
}
if(x==1)//有一个0;
{
int g=0;
for(int i=1;i<=3;i++)
{
if(num[i]==1)
g++;
}
if(g==2)//有两个1,颜色为0的那个
{
for(int i=1;i<=3;i++)
if(!num[i])
printf("%c",temp[i]);
return 0;
}
if(g==1)//有一个1,颜色为0和1个的那个
{
for(int i=1;i<=3;i++)
if(num[i]==1||!num[i])
printf("%c",temp[i]);
return 0;
}
}
printf("BGR");
return 0;
}
/*
2
BG
2
BR
2
GR
6
BGGGGG->BR
5
BGGGG ->BR
*/

Codeforces626B - Cards【模拟】的更多相关文章

  1. CF Soldier and Cards (模拟)

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

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

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

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

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

  4. [CF546C] Soldier and Cards - 模拟

    两个人玩牌,首先两个人都拿出自己手牌的最上面的进行拼点,两张拼点牌将都给拼点赢得人,这两张牌放入手牌的顺序是:先放对方的牌再放自己的.若最后有一个人没有手牌了,那么他就输了,求输出拼点的次数和赢得人的 ...

  5. A -- A. Quailty and Playing Cards 模拟 + 思考

    http://www.ifrog.cc/acm/problem/1036?contest=1005&no=0 分类,考虑Q神出的是第一张或者是第二张,然后对手出那些牌来应付. Q神出第一张和第 ...

  6. Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. queue+模拟 Codeforces Round #304 (Div. 2) C. Soldier and Cards

    题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio&g ...

  8. swjtu 2213 A Game About Cards(模拟题)

    题目链接:http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=2213 思路分析:该问题与约瑟夫问题相似:每次将前n张牌放到队列的最后 ...

  9. Java集合List模拟“洗牌”操作

    Collection工具类为操作List集合提供了几个有用的方法: reverse().shuffle().sort().swap().rotate(). 小例子: 使用shuffle(),方法模拟洗 ...

随机推荐

  1. [Binary Hacking] ABI and EABI

    Following are some general papers about ABI and EABI. Entrance https://en.wikipedia.org/wiki/Applica ...

  2. 用rsync命令删除大文件夹

    删除大文件夹 rsync 命令做同步文件用的命令 我们可以借助其快速的运行 来对大文件夹删除:原来就是 新建一个空文件夹 然后把这个空文件夹同步到一个大文件夹下面: 这样会删除大文件夹下面的内容 是高 ...

  3. Fairy Tail - Main Theme Slow Version guitar (solo)

    Хвост Феи animelodies1 (on youtube) Переписал jarrro (on vk.com)

  4. EnumChildWindows

    EnumChildWindows 函数功能:枚举一个父窗口的所有子窗口. 函数原型:BOOL EnumChildWindows(HWND hWndParent,WNDENUMPROC lpEnumFu ...

  5. BZOJ 3992: [SDOI2015]序列统计 快速幂+NTT(离散对数下)

    3992: [SDOI2015]序列统计 Description 小C有一个集合S,里面的元素都是小于M的非负整数.他用程序编写了一个数列生成器,可以生成一个长度为N的数列,数列中的每个数都属于集合S ...

  6. 3144: [Hnoi2013]切糕

    3144: [Hnoi2013]切糕 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1526  Solved: 827[Submit][Status] ...

  7. GPG key

    Creating GPG Keys - Fedora Project Wiki https://fedoraproject.org/wiki/Creating_GPG_Keys

  8. How MySQL Opens and Closes Tables refuse connections 拒绝连接的原因 file descriptors

    MySQL :: MySQL 5.7 Reference Manual :: 8.4.3.1 How MySQL Opens and Closes Tables https://dev.mysql.c ...

  9. JasperReport 中文问题解决

    1 运行环境    1.1 JasperReport 3.5    JasperReports 是iReport的核心内容.它是一个强有力的开源报表产生工具,可以将内容输出到屏幕上.打印机或生成PDF ...

  10. NBUT 1222 English Game(trie树+DP)

    [1222] English Game 时间限制: 1000 ms 内存限制: 131072 K 问题描写叙述 This English game is a simple English words ...