hdoj 5198 Strange Class 水题

Strange Class

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5198

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

HINT

题意

 

   问你名字是否为a^nb^nc^n这种类型的

 

题解:

 

乱搞嘛,先除以3,然后乱搞

~\(≧▽≦)/~啦啦啦

 

代码:

 

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff;   //无限大
const int inf=0x3f3f3f3f;
/*
inline ll read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int buf[10];
inline void write(int i) {
  int p = 0;if(i == 0) p++;
  else while(i) {buf[p++] = i % 10;i /= 10;}
  for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
  printf("\n");
}
*/
//**************************************************************************************

int main()
{
    string s;
    while(cin>>s)
    {
        int flag=1;
        if(s.size()%3!=0)
            flag=0;
        char ch1=s[0];
        for(int i=0;i<s.size()/3;i++)
            if(s[i]!=ch1)
                flag=0;
        char ch2=s[s.size()/3];
        for(int i=s.size()/3;i<s.size()/3*2;i++)
            if(s[i]!=ch2)
                flag=0;
        char ch3=s[s.size()/3*2];
        for(int i=s.size()/3*2;i<s.size();i++)
            if(s[i]!=ch3)
                flag=0;
        if(ch1==ch2||ch2==ch3||ch1==ch3)
            flag=0;
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}

 

posted @ 2015-04-04 23:30  qscqesze  阅读(289)  评论(0编辑  收藏  举报