Codeforces626B - Cards【模拟】
题意:
两张相同可以合并成相同;
两张不同可以产生另外一个不同;
求最终的可能颜色;
思路:
模拟啊。
总共也就那么几种情况,具体看挫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【模拟】的更多相关文章
- CF Soldier and Cards (模拟)
Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...
- Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...
- [CF546C] Soldier and Cards - 模拟
两个人玩牌,首先两个人都拿出自己手牌的最上面的进行拼点,两张拼点牌将都给拼点赢得人,这两张牌放入手牌的顺序是:先放对方的牌再放自己的.若最后有一个人没有手牌了,那么他就输了,求输出拼点的次数和赢得人的 ...
- A -- A. Quailty and Playing Cards 模拟 + 思考
http://www.ifrog.cc/acm/problem/1036?contest=1005&no=0 分类,考虑Q神出的是第一张或者是第二张,然后对手出那些牌来应付. Q神出第一张和第 ...
- 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 ...
- queue+模拟 Codeforces Round #304 (Div. 2) C. Soldier and Cards
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio&g ...
- swjtu 2213 A Game About Cards(模拟题)
题目链接:http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=2213 思路分析:该问题与约瑟夫问题相似:每次将前n张牌放到队列的最后 ...
- Java集合List模拟“洗牌”操作
Collection工具类为操作List集合提供了几个有用的方法: reverse().shuffle().sort().swap().rotate(). 小例子: 使用shuffle(),方法模拟洗 ...
随机推荐
- XStream 数组(List)输出结构
<!-- 期望的DOM树 --> <Articles> <item> <Title>微信SDK初步结构</Title> <Descri ...
- 简单使用 Mvc 内置的 Ioc
简单使用 Mvc 内置的 Ioc 本文基于 .NET Core 2.0. 鉴于网上的文章理论较多,鄙人不才,想整理一份 Hello World(Demo)版的文章. 目录 场景一:简单类的使用 场景二 ...
- Struts拦截器(转)
xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC &qu ...
- 【第四篇章-android平台MediaCodec】解决Observer died. Quickly, do something, ... anything...
当出现!!!Observer died. Quickly, do something, ... anything...说明你的程序已经出现严重异常了,那会是什么情况呢?这个问题困扰了我许久,后来原来是 ...
- Linux 用户和文件权限管理
Linux —— 用户权限管理 权限: 为什么需要权限管理? 1.计算机资源有限,我们需要合理的分配计算机资源. 2.Linux是一个多用户系统,对于每一个用户来说,个人隐私的保护是十分重 ...
- Filter注入对象
由于没有在web.xml文件中加上<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter ...
- linux输入子系统(5) - 学习框架
注:本系列转自: http://www.ourunix.org/post/290.html input子系统学习系列文章,是我在实际开发过程中遇到也是必须啃下去的第一个Linux驱动,所以有必要记载下 ...
- OpenGL之路(五)制作旋转飞机模型
#include <gl/glut.h> #include <gl/GLU.h> #include <gl/GL.h> #pragma comment(lib, & ...
- Windows 8实用窍门系列:20.Windows 8中的GridView使用(二)和DataTemplateSelector
在本文中所讲述内容的实例仍然沿用于上篇文章,有什么疑惑可以参考上篇文章. 一 GroupStyle 在GridView控件中我们可以对数据进行分组显示,通过对GridView的GroupStyle进行 ...
- HDU 4821 String 字符串hash
String Problem Description Given a string S and two integers L and M, we consider a substring of S ...