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. bzoj 4571: [Scoi2016]美味 (主席树)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4571 题面; 4571: [Scoi2016]美味 Time Limit: 30 Sec   ...

  2. MT【317】两次判别式

    已知$a^2+b^2+c^2-ab-bc=1$求$c$的最大值______ 注意到$2c^2-3(a^2+b^2+c^2-ab-bc)=-(c-\dfrac{3}{2}b)^2-3(a-\dfrac{ ...

  3. macOS卸载应用不彻底

    总觉得macOS卸载应用时直接移到废纸篓卸载不干净.配置文件根据Unix的习惯应该存放在用户目录下,还需要删除这些文件. ~/Library/Application Support/(应用程序名称) ...

  4. Oracle 查看链接数、创建索引等的DDL语句

    select count(*),machine from v$session group by machine 今天打算将一个数据库的索引在另一个测试库上重新创建一遍,研究了一下. set pages ...

  5. HZNU第十二届校赛赛后补题

    愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...

  6. 启动多个logstash脚本

    一台服务器上启动多个logstash脚本 # more logstash_click #!/bin/sh # Init script for logstash # Maintained by Elas ...

  7. HTML(六)HTML iframe 使用postMessage方法进行跨文档消息传递

    什么是iframe HTML内联框架元素 <iframe> 表示嵌套的浏览上下文,有效地将另一个HTML页面嵌入到当前页面中. <iframe id="inlineFram ...

  8. [再寄小读者之数学篇](2014-05-27 矩阵的迹与 Jacobian)

    (from MathFlow) 设 $A=(a_{ij})$, 且定义 $$\bex \n_A f(A)=\sex{\cfrac{\p f}{\p a_{ij}}}. \eex$$ 试证: (1) $ ...

  9. [物理学与PDEs]第5章习题10 多凸函数一个例子

    证明函数 $$\bex \hat W({\bf F})=\sedd{\ba{ll} \cfrac{1}{\det{\bf F}},&if\ \det{\bf F}>0,\\ +\inft ...

  10. 第三节,目标检测---R-CNN网络系列

    1.目标检测 检测图片中所有物体的 类别标签 位置(最小外接矩形/Bounding box) 区域卷积神经网络R-CNN 模块进化史 2.区域卷积神经网络R-CNN Region proposals+ ...