hdoj 5198 Strange Class 물 문제

7324 단어 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("
"); }
*/ //************************************************************************************** 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; } }

좋은 웹페이지 즐겨찾기