题意:

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

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

求最终的可能颜色;

思路:

模拟啊。

总共也就那么几种情况,具体看挫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. EBS OAF开发中怎样实现功能页签(Global Tab)

    EBS OAF开发中怎样实现功能页签(Global Tab) (版权声明.本人原创或者翻译的文章如需转载.如转载用于个人学习,请注明出处.否则请与本人联系,违者必究) 功能页签的实现不须要不论什么编码 ...

  2. 手机号码归属地查询免费api接口代码

    依据手机号码查询用户的卡类型.运营商.归属地.区域等信息. 手机归属地实体类 package org.wx.xhelper.model; /** * 手机归属地 * @author wangxw * ...

  3. linux输入子系统(5) - 学习框架

    注:本系列转自: http://www.ourunix.org/post/290.html input子系统学习系列文章,是我在实际开发过程中遇到也是必须啃下去的第一个Linux驱动,所以有必要记载下 ...

  4. ubuntu编译airplay

    1.alsa/asoundlib.h: No such file or directory 缺少一个库: apt-get install libasound2-dev   2.fatal error: ...

  5. iOS UIButton选中状态切换

    UIButton*payBtn = [UIButtonbuttonWithType:UIButtonTypeCustom]; payBtn.frame=CGRectMake(size.width-24 ...

  6. Windows 8实用窍门系列:20.Windows 8中的GridView使用(二)和DataTemplateSelector

    在本文中所讲述内容的实例仍然沿用于上篇文章,有什么疑惑可以参考上篇文章. 一 GroupStyle 在GridView控件中我们可以对数据进行分组显示,通过对GridView的GroupStyle进行 ...

  7. Wordpress播客网站搭建

  8. POJ3376 Finding Palindromes —— 扩展KMP + Trie树

    题目链接:https://vjudge.net/problem/POJ-3376 Finding Palindromes Time Limit: 10000MS   Memory Limit: 262 ...

  9. Objective-C - - 字符串与数字互相转换

    NSString *string = @"123"; // 1.字符串转int int intString = [string intValue]; // 2.int装字符串 NS ...

  10. UVA - 10004 Bicoloring(判断二分图——交叉染色法 / 带权并查集)

    d.给定一个图,判断是不是二分图. s.可以交叉染色,就是二分图:否则,不是. 另外,此题中的图是强连通图,即任意两点可达,从而dfs方法从一个点出发就能遍历整个图了. 如果不能保证从一个点出发可以遍 ...