题意:

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

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

求最终的可能颜色;

思路:

模拟啊。

总共也就那么几种情况,具体看挫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. DoubleViewPager

    https://github.com/eltld/DoubleViewPager https://github.com/eltld/DoubleViewPagerSample

  2. gcc在出现错误的时候停止编译 -Wfatal-errors

    有时候我们编译一个大的项目的时候.会出现非常多错误使得屏幕堆满了非常多没用的信息.普通情况下我们须要找到首次出现错误的地方,在gcc中加入编译选项能够使编译停止在第一次出现错误的地方: $ gcc - ...

  3. SSM整理笔记3——配置解析

    github:https://github.com/lakeslove/SSM 项目的目录结构如下 首先,配置web.xml <?xml version="1.0" enco ...

  4. lint (software)

    lint (software) - Wikipedia https://en.wikipedia.org/wiki/Lint_(software) A linter or lint refers to ...

  5. 如何使用CSS3 @font-face

    @font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕只能使用Web安全字体,你们当中或许有许 ...

  6. Deep Learning 33:读论文“Densely Connected Convolutional Networks”-------DenseNet 简单理解

    一.读前说明 1.论文"Densely Connected Convolutional Networks"是现在为止效果最好的CNN架构,比Resnet还好,有必要学习一下它为什么 ...

  7. python selenium实现百度搜索

    1.环境 python2.7+selenium+phantomjs+linux 2.代码 #-*-coding:utf-8 -*- from selenium import webdriver fro ...

  8. Java 8 新的时间日期 API

    1. 概述 1.1 简介 Java 8 引入了一套全新的时间日期API,操作起来更简便.简单介绍下,LocalDate和LocalTime和LocalDateTime的使用: java.util.Da ...

  9. 【Selenium】验证是否按照字母顺序排列, 不区分大小写

    验证是否按照字母顺序排列, 不区分大小写 for(int j=0;j<s.length-1;j++){ String temp1=s[j].toLowerCase(); String temp2 ...

  10. Lucene 的四大索引查询 ——bool 域搜索 通配符 范围搜索

    Lucene 的四大索引查询  清单1:使用布尔操作符 Java代码      //Test boolean operator blic void testOperator(String indexD ...