Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember.

FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:

It must contain at least one vowel.

It cannot contain three consecutive vowels or three consecutive consonants.

It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.

(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.

InputThe input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters. 
OutputFor each password, output whether or not it is acceptable, using the precise format shown in the example. 
Sample Input

a
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end

Sample Output

<a> is acceptable.
<tv> is not acceptable.
<ptoui> is not acceptable.
<bontres> is not acceptable.
<zoggax> is not acceptable.
<wiinq> is not acceptable.
<eep> is acceptable.
<houctuh> is acceptable. 思路:
合格的字符串需要满足三个条件。
(1)至少一个元音;
(2)不能有3个连续的元音或辅音;
(3)不能有连续相同的字母,除非是 ‘e' 或 'o';
#include<bits/stdc++.h>
using namespace std;
#define N 1000001
char s[N];
int main()
{
while(scanf("%s",s),strcmp(s,"end")){ //end 结束
int len=strlen(s),a=0,b=0; // a 表示连续的元音, b 表示连续的辅音
int x = 0,y = 0; //y 表示是否出现过元音,x 表示是否有不符合条件2、3的情况
for(int i=0;i<len;i++){
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' ||s[i]=='u'){
y = 1;
a++;
b=0;
}
else{
b++,a=0;
}
if(a==3 || b==3){
x = 1;
break;
}
if(i!=0 && s[i]!='e'&&s[i]!='o' && s[i]==s[i-1]){
x = 1;
break;
}
}
if(x || !y){
printf("<%s> is not acceptable.\n",s);
}
else{
printf("<%s> is acceptable.\n",s);
}
}
return 0;
}

  

EHDU-1039 asier Done Than Said?的更多相关文章

  1. 【hihoCoder】1039 : 字符消除

    题目:http://hihocoder.com/problemset/problem/1039 给定一个字符串s,只包含'A', 'B', 'C'三种字符 1. 向 s 的任意位置 (包括头和尾) 中 ...

  2. hihoCoder 1039字符消除 (字符串处理)

    http://hihocoder.com/problemset/problem/1039 因为字符串只由3种字母组成,并且插入的字符也只能是这三种字符的其中一个,那么可以考虑枚举这三个字符其中一个字符 ...

  3. 1039. Course List for Student (25)

    题目链接:http://www.patest.cn/contests/pat-a-practise/1039 题目: 1039. Course List for Student (25) 时间限制 2 ...

  4. PAT-乙级-1039. 到底买不买(20)

    1039. 到底买不买(20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小红想买些珠子做一串自己喜欢的珠串 ...

  5. poj 1039 Pipe(叉乘。。。)

    题目:http://poj.org/problem?id=1039 题意:有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从 ...

  6. 【宽搜】XMU 1039 Treausure

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1039 题目大意: 给定n,m(1<=n,m<=1000),一张n*m的地图 ...

  7. 【hihocoder 1039 字符串消除】模拟

    题目链接:http://hihocoder.com/problemset/problem/1039 题意:给定一个只由{A, B, C}组成的字符串s,长度为n, 故包含n+1个空隙:现要求在某个空隙 ...

  8. POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划)

    POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划) Descri ...

  9. HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)

    并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...

  10. 【hihoCoder】#1039 : 字符消除 by C solution

    #1039 : 字符消除 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi最近在玩一个字符消除游戏.给定一个只包含大写字母"ABC"的字符串s,消 ...

随机推荐

  1. Codeforces 1082B Vova and Trophies(前缀+后缀)

    题目链接:Vova and Trophies 题意:给定长度为n的字符串s,字符串中只有G和S,只允许最多一次操作:任意位置的两个字符互换.求连续G的最长长度. 题解:维护pre和pr,nxt和nx. ...

  2. 中间件方法必须返回Response对象实例(tp5.1+小程序结合时候出的问题)

    前言:在最近开发小程序通过中间件检查是否携带token时候报的一个错误 解决方法: 根据手册中需要return出去才可以不报错

  3. CSS font字体知识学习

    字体系列 [1]5种通用字体系列:拥有相似外观的字体系列 serif字体:字体成比例,且有上下短线(衬线字体),包括Times\Georgia\New century Schoolbook sans- ...

  4. 使用Jenkins docker镜像运行Jenkins服务

    需求 使用docker技术管理Jenkins服务器.避免多次部署需要重复安装的重复工作,且可以方便迁移到新的服务器. Jenkins docker镜像 https://hub.docker.com/_ ...

  5. Java(6)for循环

    一.for循环的使用场合 1.1.while循环——先判断,再循环 while(1.条件表达式){      //2.循环操作      //3.更改循环条件表达式 } 1.2.do…while——先 ...

  6. 2.5 elif

    elif 想一想: if能完成当xxx时做事情 if-else能完成当xxx时做事情1,否则做事情2 如果有这样一种情况:当xxx1满足时做事情1:当xxx1不满足.xxx2满足时做事情2:当xxx2 ...

  7. rem是怎么计算的

    「rem」是指根元素(root element,html)的字体大小,从遥远的 IE6 到版本到 Chrome 他们都约好了,根元素默认的 font-size 都是 16px. rem是通过根元素进行 ...

  8. PhpStorm+xdebug调试——更新

    之前写过一篇<PhpStorm+xdebug+postman调试>,但是经过后来一段时间的使用,发现有些累赘.这里介绍一种比较简单方便的操作. 在上一篇文章中有一段“ 7.设置Server ...

  9. windows连接oracle数据库

    本以为很简单,结果发现还是有些坑啊 1. 安装cx_oracle pip install cx_oracle 或者用whi文件,这样你能知道版本号那些https://www.lfd.uci.edu/~ ...

  10. LeetCode第十题-正则表达式匹配

    Regular Expression Matching 问题简介:给定字符串,给定匹配模式,判断字符串是否满足匹配模式 问题详解:一共有两种特殊模式: ‘.’ 匹配任何单个字符 ‘*’ 匹配前面元素的 ...