题意:

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

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

求最终的可能颜色;

思路:

模拟啊。

总共也就那么几种情况,具体看挫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. c++引用和const 用法 数组 指针

    非const引用,只能用object为其赋值: <c++primer>P52 而const引用则可以用临时变量为其赋值: 如: const int &r = 32://可以 int ...

  2. ngnix

    nginx的平滑重启 博客分类: nginx nginx平滑重启  在研发过程中,修改nginx的配置文件nginx.conf是很平常的事,需要重启nginx.如果我们直接reload是有一定风险的, ...

  3. HDU 1040 As Easy As A+B [补]

    今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...

  4. 面向接口的webservice发布方式

    import javax.jws.WebService; /**面向接口的webservice发布方式 */ @WebService public interface JobService { pub ...

  5. postgres源码目录结构

    1.第一级目录介绍 |_postgres |_aclocal.m4------------config用的文件的一部分 |_config----------------config文件目录 |_con ...

  6. 程序员笔记|如何编写高性能的Java代码

    一.并发 Unable to create new native thread …… 问题1:Java中创建一个线程消耗多少内存? 每个线程有独自的栈内存,共享堆内存 问题2:一台机器可以创建多少线程 ...

  7. HDU 6138 Fleet of the Eternal Throne 后缀数组 + 二分

    Fleet of the Eternal Throne Problem Description > The Eternal Fleet was built many centuries ago ...

  8. 获取Android设备无线和以太网MAC地址

    package com.raycloud.wolf.blogformac; import android.net.wifi.WifiManager; import android.support.v7 ...

  9. Ural 1635 Mnemonics and Palindromes(DP)

    题目地址:space=1&num=1635">Ural 1635 又是输出路径的DP...连着做了好多个了. . 状态转移还是挺简单的.要先预处理出来全部的回文串,tag[i] ...

  10. ubuntu 本地和服务器scp文件传输

    安装 SSH(Secure Shell) 服务以提供远程管理服务 sudo apt-get install ssh SSH 远程登入 Ubuntu 机 ssh username@192.168.0.1 ...