hdu 5198 Strange Class

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.
 

 

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.
 

 

Output
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
 

 

Sample Input
abc
bc
 

 

Sample Output
YES
NO

 

   超水之题,不解释。

 

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<map>
 4 using namespace std;
 5 map<int,int>p;
 6 int main()
 7 {
 8     char s[20];
 9     int l,i,k;
10     while (~scanf("%s",&s))
11     {
12         k=0;
13         l=strlen(s);
14         if (l%3!=0) k=1;
15         for (i=1;i<l/3;i++)
16         if (s[i]!=s[i-1]) k=1;
17         for (i=l/3+1;i<l/3*2;i++)
18         if (s[i]!=s[i-1]) k=1;
19         for (i=l/3*2+1;i<l;i++)
20         if (s[i]!=s[i-1]) k=1;
21         if (s[0]==s[l/3]||s[0]==s[l-1]||s[l/3]==s[l-1]) k=1;
22         if (k) printf("NO\n");
23         else printf("YES\n");
24     }
25 }

 

转载于:https://www.cnblogs.com/pblr/p/4755725.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值