hdu 5198 Strange Class(模拟)
来源:互联网 发布:区域分割粒子群算法 编辑:程序博客网 时间:2024/06/06 03:51
Strange Class
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1123 Accepted Submission(s): 571
Problem Description
In Vivid’s school, there is a strange class(SC). In SC, the students’ names are very strange. They are in the same format: anbncn (a,b,c must not be the same with each other). For example studens whose names are“abc”,”ddppqq” are in SC, however studens whose names are “aaa”,“ab”,”ddppqqq” are not in SC.
Vivid makes friends with so many students, he wants to know who are in SC.
Vivid makes friends with so many students, he wants to know who are in SC.
Input
There are multiple test cases (about 10), each case will give a string S which is the name of Vivid’s friend in a single line.
Please process to the end of file.
[Technical Specification]
1≤|S|≤10 .
|S| indicates the length of S.
S only contains lowercase letter.
Please process to the end of file.
[Technical Specification]
|S| indicates the length of S.
S only contains lowercase letter.
Output
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
Sample Input
abcbc
Sample Output
YESNO
思路:简单题,直接模拟
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;char a[15];int solve(int len){ if(a[0]==a[len]||a[0]==a[len*2]||a[len]==a[len*2]) return 0; for(int i=1; i<len; i++) if(a[i]!=a[i-1]) return 0; for(int i=len+1; i<2*len; i++) if(a[i]!=a[i-1]) return 0; for(int i=2*len+1; i<3*len; i++) if(a[i]!=a[i-1]) return 0; return 1;}int main(){ while(~scanf("%s",a)) { int len=strlen(a); if(len%3!=0) { printf("NO\n"); continue; } int ans=solve(len/3); if(ans) printf("YES\n"); else printf("NO\n"); } return 0;}
0 0
- hdu 5198 Strange Class(模拟)
- hdu 5198 Strange Class
- HDU 5198 Strange Class
- HDU - 5198 - Strange Class
- 【BestCoder】HDU 5198 Strange Class
- HDU-5198-Strange Class(Java+注意细节!)
- HDU - 5198 - Strange Class && 5199 - Gunner
- HDU 5198 /BC 36A Strange Class
- BestCoder Round #36(Strange Class-模拟)
- hdu 2899 Strange fuction 模拟退火
- Strange Class
- Strange Class
- Strange Class
- 【CUGBACM15级BC第36场 A】hdu 5198 Strange Class
- Hdu 2899 Strange fuction(二分三分可做,模拟退火解法)
- Strange fuction(hdu 2899)
- HDU 1548 A strange lift(递归模拟标记)
- codeforces 305A Strange Addition (模拟)
- 【杭电1702】基础 队列和栈
- Cocos2d-x优化中关于背景图片优化
- Radar Installation
- VS2010使用存在的问题
- 简单工厂模式C++实现
- hdu 5198 Strange Class(模拟)
- NSArray && NSDictionary
- Eclipse找出所有中文字符方法(全球化开发方式)
- 不要让忙碌成为逃避学习的借口--Blog开通,博主介绍
- Spring Cache
- 观察者模式
- 代码中动态该变shape的颜色
- DES加解密算法
- 关于java中map存储多行的小程序(一键对多值)