626B-Cards
来源:互联网 发布:js 设置控件不可用 编辑:程序博客网 时间:2024/04/30 13:33
题意:由RGB三个字母组成的字符串,任两个字母组合,若相同则为本身,若两个字母不同则组合后为第三个字母。输出不同组合方法得出的字符串。
分析:发现cf 的题目真灵活,这题还是看了题解,哎,,,,,
先统计三个字母的个数,然后对每个字母单独讨论,共有三种情况,列举一下,输出就好。题目要求是按字典序,所以注意输出顺序。
#include<bits/stdc++.h>using namespace std;int main(){ int a=0,b=0,c=0,n; string s; cin>>n>>s; for(int i=0;i<s.size();i++) { if(s[i]=='B') a++; if(s[i]=='G') b++; if(s[i]=='R') c++; } if( (!b&&!c) || (b>=1 && c>=1) || (b>1 || c>1) &&a>=1 ) cout<<'B'; if( (!a&&!c) || (a>=1 && c>=1) || (a>1 || c>1) &&b>=1 ) cout<<'G'; if( (!a&&!b) || (a>=1 && b>=1) || (a>1 || b>1) &&c>=1 ) cout<<'R'; return 0;}
0 0
- 626B-Cards
- CodeForces-626B-Cards
- CF 626 B. Cards
- Codeforces 626B Cards(规律)
- CodeForces 626B-Cards【DFS】
- CodeForces 626B:Cards【模拟】
- Codeforces 626B Cards 【BFS or 讨论】
- CodeForces 626 B. Cards(水~)
- CodeForces - 626B Cards (全排列&模拟)
- Codeforces--626B--Cards(模拟)
- CodeForces 626B Cards(数学思维)
- codeforces-626-B. Cards(简单模拟)
- cf B. Cards
- codeforce-628B-Cards
- B - Bear and Five Cards
- B. Game of Credit Cards
- codeforces 830B. Cards Sorting
- Codeforces B. Cards Sorting 【瞎搞】
- 文件与目录操作
- poj 3624 Charm Bracelet
- ThreadLocal 和神奇的 0x61c88647
- .NET Task的新认识
- 数据库常考笔试题
- 626B-Cards
- Pentest - psmsf
- neuq oj 1050: 谭浩强C语言(第三版)习题6.6 C++
- nyist 49 开心的小明(01背包)
- web学习博客2016/2/20
- python的邮箱正则的一些改进
- String、StringBuffer与StringBuilder之间区别
- 好气,action死活取不到input中的值
- .Net中访问数据库学习笔记