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;
    }
}
时间: 2024-11-14 05:18:19

hdoj 5198 Strange Class 水题的相关文章

hdoj 1106 排序 【水题】

排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 35499    Accepted Submission(s): 10042 Problem Description 输入一行数字,如果我们把这行数字中的'5'都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以'0'开头,这些头部的'0'应该被忽略掉,除非这个整数就是

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of

水题 HDOJ 4716 A Computer Graphics Problem

题目传送门 1 /* 2 水题:看见x是十的倍数就简单了 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const int MAXN = 1e4 + 10; 13

水题 HDOJ 4727 The Number Off of FFF

题目传送门 1 /* 2 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const in

HDOJ/HDU 1256 画8(绞下思维~水题)

Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一个整数,字符表示画笔,整数(>=5)表示高度. Output 画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形. 每画一个"8"应空一行,但最前和最后都无空

HDOJ/HDU 2560 Buildings(嗯~水题)

Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, the green grids represent the buidings. Given the size of the HZNU Campus, and the color of each grid, you should count how many green grids in the N

POJ 3030. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13136   Accepted: 9077 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends.

HDU - 4813 Hard Code (长春赛区水题)

Description Some strange code is sent to Da Shan High School. It's said to be the prophet's note. The note is extremely hard to understand. However, Professor Meng is so smart that he successfully found the pattern of the code. That is, the length of

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b