HDU 5198 Strange Class
来源:互联网 发布:怎么删除受限的网络 编辑:程序博客网 时间:2024/05/16 09:23
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<stdio.h>#include<iostream>#include<algorithm>#include<map>#include<queue>#include<stack>#include<vector>#include<cstdlib>#include<functional>#include<string>#include<cstring>using namespace std;const int maxn = 4;char s[100];void check(){ int n = strlen(s); if (n % 3 != 0) { printf("NO\n"); return; } for (int i = 0; i < n / 3; i++) if (s[i] != s[0]) { printf("NO\n"); return; } for (int i = n / 3; i < 2 * n / 3; i++) if (s[i] != s[n / 3]) { printf("NO\n"); return; } for (int i = 2 * n / 3; i < n; i++) if (s[i] != s[2 * n / 3]) { printf("NO\n"); return; } if (s[0] == s[n / 3] || s[n / 3] == s[n / 3 * 2] || s[0] == s[n / 3 * 2]) { printf("NO\n"); return; } printf("YES\n");}int main(){ while (scanf("%s", s) != EOF) check();}
0 0
- hdu 5198 Strange Class
- HDU 5198 Strange Class
- HDU - 5198 - Strange Class
- 【BestCoder】HDU 5198 Strange Class
- HDU - 5198 - Strange Class && 5199 - Gunner
- HDU 5198 /BC 36A Strange Class
- hdu 5198 Strange Class(模拟)
- HDU-5198-Strange Class(Java+注意细节!)
- Strange Class
- Strange Class
- Strange Class
- 【CUGBACM15级BC第36场 A】hdu 5198 Strange Class
- HDU 1882 Strange Billboard
- HDU A strange lift
- HDU 2899 Strange fuction
- hdu 2899 Strange fuction
- hdu 2899 Strange fuction
- HDU 2899 Strange fuction
- RK哈希、线性探测
- ubuntu14.04下evolution配置163邮箱
- 正如最高人民法院常务副院长沈德咏所指出的
- sql server 2008 R2启动不了,报错,错误40,2
- 错放一个真正的罪犯,天塌不下来;
- HDU 5198 Strange Class
- 特别是错杀了一个人,天就塌下来了
- 在这个意义上,曾经的“杀人疑犯”马顺贵被无罪释放
- 阿里巴巴 2015 实习笔试题 分布式系统中的RPC请求经常出现乱序的情况 写一个算法来将一个乱序的序列保序输出
- ubuntu 下配置/编译/运行 cocos2dx项目
- HDU 5199 Gunner
- 原则,宁肯错放不可错判。这无疑值得称赞
- HDU 5200 Trees
- 我们也可以从这样的案件中,学会正视