【CUGBACM15级BC第36场 A】hdu 5198 Strange Class
来源:互联网 发布:阿里云实例快照是什么 编辑:程序博客网 时间:2024/06/05 14:13
Strange Class
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1234 Accepted Submission(s): 641
Total Submission(s): 1234 Accepted Submission(s): 641
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
题意:问给出的字符串是否是三个不同字符组成的,三个字符可以有多个。但是注意要连续,比如ababcc是不合法的
思路:简单题,直接模拟
#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
- 【CUGBACM15级BC第36场 A】hdu 5198 Strange Class
- 【CUGBACM15级BC第24场 C】hdu 5152 A Strange Problem
- 【CUGBACM15级BC第15场 A】hdu 5083 Love
- 【CUGBACM15级BC第17场 A】hdu 5100 Chessboard
- 【CUGBACM15级BC第23场 A】hdu 5146 Sequence
- 【CUGBACM15级BC第8场 A】hdu 4989 Summary
- 【CUGBACM15级BC第31场 A】hdu 5178 pairs
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- 【CUGBACM15级BC第36场 B】hdu 5199 Gunner
- HDU 5198 /BC 36A Strange Class
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- 【CUGBACM15级BC第11场 A】hdu 5054 Alice and Bob
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第18场 A】hdu 5104 Primes Problem
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- 【CUGBACM15级BC第19场 A】hdu 5108 Alexandra and Prime Numbers
- 【CUGBACM15级BC第21场 A】hdu 5138 CET-6 test
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- Android系统源码分析--Context
- Git 提交代码
- 并发基础_11_并发_容器_ConcurrentLinkedQueue
- 数据传送
- (作业)Swift枚举、类、派生、协议
- 【CUGBACM15级BC第36场 A】hdu 5198 Strange Class
- 什么是敏捷过程?
- Spark的Application和依赖的公共jar包单独存放
- JAVA自带的定时器
- Android
- git常用命令
- springmvc自定义异常处理器
- 杂项
- HDU:4004 The Frog's Games<二分>