Strange Class

Strange Class

Accepts: 519

Submissions: 1749

Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 65536/65536 K (Java/Others)

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


问题描述
在Vivid的学校里,有一个奇怪的班级(SC).在SC里,这些学生的名字非常奇怪。他们的名字形式是这样的anbncn(a,b,c两两不相同。).例如,叫”abc”,”ddppqq”的学生是在SC里的,然而叫”aaa”,”ab”,”ddppqqq”的同学并不是在SC里的。
Vivid交了许多的朋友,他想知道他们之中哪些人是在SC里的。

输入描述

多组测试数据(大概10组),每一个数据在一行中给出一个字符串S,代表Vivid一个朋友的名字。
请处理到文件末尾。

[参数约定]
1≤|S|≤10.
|S| 是指S的长度.
S 只包含小写字母.

输出描述

对于每一个数据,如果Vivid的朋友是SC里的,那么输出YES,否则输出NO。

输入样例

abc
bc

输出样例

YES
NO
<span style="font-size:24px;">思路:昨天交了几次就是wa了,仔细读读题,发现如果aabbaa的话,我当时就认为是sc了,实际不是,<span style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; line-height: 1.42857143; white-space: pre-wrap;">所以还要再判断存储的字符是不是一样的。。控制一下。不用重新排序,就是直接按照题目给的顺序做。</span></span>
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char s[20],h[20];
    int len,i,a[20],k,g,count;
  while(cin>>s)
  {
      k=0;
      g=0;
     len=strlen(s);
     for(i=0;i<len;i++)  //aabbaa
     {
         count=1;
         while(i<len-1&&s[i]==s[i+1])
         {
              count++;
              i++;
         }
        a[k++]=count;
        h[g++]=s[i];
     }
     if(k==3 &&h[0]!=h[1] &&h[1]!=h[2] &&h[0]!=h[2] &&a[0]==a[1]&&a[0]==a[2]&&a[1]==a[2])
     {

         cout<<"YES"<<endl;
     }
     else
         cout<<"NO"<<endl;
  }
    return 0;
}
				
时间: 2024-08-01 04:07:36

Strange Class的相关文章

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,

数论F - Strange Way to Express Integers(不互素的的中国剩余定理)

F - Strange Way to Express Integers Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers.

A strange lift

点击打开链接 题意:有n层楼层,现在在每一层有两个按钮,分别为up和down,按动按钮时,可以向上或向下跳动num[ i ]层:问能否以最少的次数从A到B层,不能输出-1: 解析:构图,将从i层到按动按钮后跳转的楼层,看作连通状态,赋值为1,这样就转换成单源最短路问题: #include<iostream> #include<cstring> #include<cstdio> using namespace std; const int maxn = 500; cons

zoj 3332 Strange Country II

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3332 Description You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to trav

poj 2891 Strange Way to Express Integers

http://poj.org/problem?id=2891 这道题的题意是:给你多个模性方程组:m mod ai=ri 求最小的m: 中国剩余定理 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define ll long long 5 using namespace std; 6 7 ll gcd(ll a,ll b,ll &x,ll &y) 8 { 9 if(!

poj——2891 Strange Way to Express Integers

Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 16839   Accepted: 5625 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is

HDU 1548 A strange lift【不错的最短路,spfa】

A strange lift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 21281    Accepted Submission(s): 7786 Problem Description There is a strange lift.The lift can stop can at every floor as you want

HDU 1548.A strange lift

A strange lift Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u SubmitStatusPracticeHDU 1548 Description There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N)

扫描线 - UVALive - 6864 Strange Antennas

Strange Antennas Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=87213 Mean: 给你一个N*N的网格,有M个雷达,每个雷达的扫射区域是一个直角边长为P的等腰直角三角形,能够向以直角顶点为中心的四个象限扫射. 雷达之间存在信号屏蔽,只有被奇数个雷达扫射到的区域才能被信号覆盖.求被信号覆盖的区域是多少. analyse: 因为给的都是整数点,这样就不涉及到计算几何了. N

Strange Way to Express Integers(中国剩余定理+不互质)

Strange Way to Express Integers Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2891 Appoint description:  System Crawler  (2015-04-27) Description Elina is reading a book written by Rujia Liu,