BestCoder Round #36 (hdu5198)Strange Class(水题)
2015-04-06 23:50
330 查看
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
[align=left]Sample Input[/align]
abc
bc
[align=left]Sample Output[/align]
YES
NO
必须是连续的字母。。。被坑了
Strange Class
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
[align=left]Sample Input[/align]
abc
bc
[align=left]Sample Output[/align]
YES
NO
必须是连续的字母。。。被坑了
//##################### //Author:fraud //Blog: http://www.cnblogs.com/fraud/ //##################### #include <iostream> #include <sstream> #include <ios> #include <iomanip> #include <functional> #include <algorithm> #include <vector> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <climits> #include <cctype> using namespace std; #define XINF INT_MAX #define INF 0x3FFFFFFF #define MP(X,Y) make_pair(X,Y) #define PB(X) push_back(X) #define REP(X,N) for(int X=0;X<N;X++) #define REP2(X,L,R) for(int X=L;X<=R;X++) #define DEP(X,R,L) for(int X=R;X>=L;X--) #define CLR(A,X) memset(A,X,sizeof(A)) #define IT iterator typedef long long ll; typedef pair<int,int> PII; typedef vector<PII> VII; typedef vector<int> VI; int vis[1010]; int num[1010]; int main() { ios::sync_with_stdio(false); string s; while(cin>>s){ int len=s.length(); CLR(vis,0); CLR(num,0); int ans=1; int cs=0; int k=len/3; if(k*3!=len)ans=0;if(ans){ char str=s[0]; for(int i=0;i<k;i++){ if(s[i]!=str)ans=0; } str=s[k]; if(s[k]==s[k-1])ans=0; for(int i=k;i<len-k;i++){ if(s[i]!=str)ans=0; } str=s[len-k]; if(str==s[len-k-1])ans=0; if(str==s[0])ans=0; for(int i=len-k;i<len;i++){ if(s[i]!=str)ans=0; } } if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
相关文章推荐
- hdoj 5198 Strange Class 水题
- BestCoder Round #36 (hdu5200)Strange Class(离线)
- bestcoder#36-13981Strange Class字符串是否是a^n+b^n+c^n
- HDU-5198-Strange Class(Java+注意细节!)
- 暑假集训第三周周三赛 STL C - Strange Class 字符相同 SC数
- Hdu 6015 Skip the Class【水题】
- Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题
- hdu 5198 Strange Class(模拟)
- HDU - 5198 - Strange Class && 5199 - Gunner
- A strange lift HDU 1548 queue BFS 简单 水题
- Codeforces Round #389 (Div. 2)A. Santa Claus and a Place in a Class(水题)
- BestCoder Round #36(Strange Class-模拟)
- 【BestCoder】HDU 5198 Strange Class
- VC的classView不能显示所有类信息
- ProbeException解决办法:There is no WRITEABLE property named 'id' in class 'java.lang.String'
- 连接mysql的时候出现:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- CodeForces 20B Equation 水题
- 真机报错:dyld: Symbol not found:OBJC_CLASS_$_CIKernel
- Java ClassLoader深入讲解
- 类-Class