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

  1. a
  2. tv
  3. ptoui
  4. bontres
  5. zoggax
  6. wiinq
  7. eep
  8. houctuh
  9. end

Sample Output

  1. <a> is acceptable.
  2. <tv> is not acceptable.
  3. <ptoui> is not acceptable.
  4. <bontres> is not acceptable.
  5. <zoggax> is not acceptable.
  6. <wiinq> is not acceptable.
  7. <eep> is acceptable.
  8. <houctuh> is acceptable.
  9.  
  10. 思路:
合格的字符串需要满足三个条件。
(1)至少一个元音;
(2)不能有3个连续的元音或辅音;
(3)不能有连续相同的字母,除非是 ‘e' 或 'o';
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define N 1000001
  4. char s[N];
  5. int main()
  6. {
  7. while(scanf("%s",s),strcmp(s,"end")){ //end 结束
  8. int len=strlen(s),a=0,b=0; // a 表示连续的元音, b 表示连续的辅音
  9. int x = 0,y = 0; //y 表示是否出现过元音,x 表示是否有不符合条件2、3的情况
  10. for(int i=0;i<len;i++){
  11. if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' ||s[i]=='u'){
  12. y = 1;
  13. a++;
  14. b=0;
  15. }
  16. else{
  17. b++,a=0;
  18. }
  19. if(a==3 || b==3){
  20. x = 1;
  21. break;
  22. }
  23. if(i!=0 && s[i]!='e'&&s[i]!='o' && s[i]==s[i-1]){
  24. x = 1;
  25. break;
  26. }
  27. }
  28. if(x || !y){
  29. printf("<%s> is not acceptable.\n",s);
  30. }
  31. else{
  32. printf("<%s> is acceptable.\n",s);
  33. }
  34. }
  35. return 0;
  36. }

  

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. Scrapy-redis 组件

    scrapy-redis 简介 scrapy-redis是scrapy框架基于redis数据库的组件,用于scrapy项目的分布式开发和部署. 特征 分布式爬取 可以启动多个spider工程,相互之间 ...

  2. Linux基本命令总结(九)

    接上篇: 46,scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.可能会稍微影响一下 ...

  3. mysql加速导入数据的简单设置

    mysql加速导入数据的简单设置 # 修改前查询参数值 show variables like 'foreign_key_checks'; show variables like 'unique_ch ...

  4. Numpy 系列(九)- 结构化数组

      简介 之前我们操作Numpy的数组时,都是通过索引来操作的.针对二维数组,使用索引可以完成对行.列的操作.但是这是非常不直观的.可以把二维数组想象成一个excel表格,如果表格没有列名,操作起来会 ...

  5. 用Java编写第一个区块链

    原文地址:https://www.cnblogs.com/zacky31/p/9057193.html 目标: 创建一个最基本的“区块链” 实现一个简单的挖矿系统 前提: 对面向对象编程有一定的基础 ...

  6. Shiro 系列: 简单命令行程序示例

    在本示例中, 使用 INI 文件来定义用户和角色. 首先学习一下 INI 文件的规范. =======================Shiro INI 的基本规范================== ...

  7. [物理学与PDEs]第4章第3节 一维反应流体力学方程组 3.3 一维反应流体力学方程组的数学结构

    一维理想反应流体力学方程组是一阶拟线性双曲组.

  8. [物理学与PDEs]第2章习题11 Lagrange 形式的一维理想流体力学方程组在强间断线上的间断连接条件

    对由第 10 题给出的 Lagrange 形式的一维理想流体力学方程组, 给出解在强间断线上应满足的间断连接条件 (假设体积力 $F\equiv 0$). 解答: $$\beex \bea \sez{ ...

  9. [物理学与PDEs]第2章习题6 有旋的 Navier-Stokes 方程组

    试证明: 由 Navier-Stokes 方程组描述的流体运动一般总是有旋的, 即若 $\rot{\bf u}={\bf 0}$, 则 Navier-Stokes 方程组 (3. 4)-(3. 5) ...

  10. File Upload XSS

    A file upload is a great opportunity to XSS an application. User restricted area with an uploaded pr ...