HDU ACM 1039 Easier Done Than Said? 水题

分析:判断密码是否安全。

三个条件:至少一个元音字母,连续三个字母不能同时为元音或辅音,连续两个字母不能相同,但"ee"和"oo"除外。

#include<iostream>
using namespace std;

bool isyuan(char c)
{
	return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}

bool judge(char a[])
{
	int i,l;

	l=strlen(a);
	for(i=0;a[i];i++)
		if(isyuan(a[i])) break;
	if(!a[i]) return false;        //是否有元音

	for(i=0;i<l-2;i++)
	{
		if(isyuan(a[i]) && isyuan(a[i+1]) && isyuan(a[i+2])||!isyuan(a[i]) && !isyuan(a[i+1]) && !isyuan(a[i+2]))
			return false;
		if(a[i]==a[i+1] && a[i]!='e' && a[i]!='o')
			return false;
	}
	if(a[i]==a[i+1] && a[i]!='e' && a[i]!='o')
			return false;
	return true;
}

int main()
{
	char a[30];

	while(scanf("%s",a),strcmp(a,"end"))
	{
		printf("<%s> ",a);
		puts(judge(a)?"is acceptable." : "is not acceptable.");
	}
    return 0;
}
时间: 2024-12-19 03:17:58

HDU ACM 1039 Easier Done Than Said? 水题的相关文章

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

HDU 5832 A water problem(某水题)

HDU 5832 A water problem(某水题) Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   Problem Description - 题目描述 Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is

hdu 1312 Red and Black(BFS水题)

Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9684    Accepted Submission(s): 6021 Problem Description There is a rectangular room, covered with square tiles. Each tile is colore

[ACM] Color the ball [线段树水题][数组开大]

Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N).  当N

HDU 2674 N!Again (数论-水题)

N!Again Problem Description WhereIsHeroFrom:             Zty, what are you doing ? Zty:                                     I want to calculate N!...... WhereIsHeroFrom:             So easy! How big N is ? Zty:                                    1 <=

HDU 4143 A Simple Problem(数论-水题)

A Simple Problem Problem Description For a given positive integer n, please find the smallest positive integer x that we can find an integer y such that y^2 = n +x^2. Input The first line is an integer T, which is the the number of cases. Then T line

hdu 5131 Song Jiang&#39;s rank list (水题)

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 253    Accepted Submission(s): 128 Problem Description <Shui Hu Zhuan>,also <Water Margin>was written by Shi Nai'

hdu 4274 Spy&amp;#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the

URAL 1039 Anniversary Party 树形DP 水题

1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical structure of employees; that is, the supervisor rela