HDU 1039 Easier Done Than Said?
Easier Done Than Said?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12751 Accepted Submission(s): 6165
Problem Description
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.
Input
The 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.
Output
For 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.
Source
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039
分析:
判读条件
1:有元音字母
2:不能三个连续元音或辅音
3.不能连续两个相同的字母,除非ee或oo
下面给出AC代码:
1 #include <bits/stdc++.h>
2 using namespace std;
3 int main()
4 {
5 char str[25];
6 int a[25];
7 while(scanf("%s",str)&&strcmp("end",str))
8 {
9 int len=strlen(str);
10 int flag=1;
11 int sum=0;//sum 标记元音的个数
12 for(int i=0;i<len;i++)
13 {
14 switch(str[i])
15 {
16 case 'a':
17 case 'e':
18 case 'i':
19 case 'o':
20 case 'u':a[i]=1;sum++;break;
21 default :a[i]=0;
22 }
23 if(i>0&&str[i]==str[i-1]&&str[i]!='e'&&str[i]!='o')//2个连续的相同音,排除e/o
24 {
25 flag=0;
26 break;
27 }
28 if(i>1&&a[i]==a[i-1]&&a[i-1]==a[i-2])// 连续三个相连的元音或辅音 注意 i满足的条件,
29 {
30 flag=0;
31 break;
32 }
33 }
34 if(sum&&flag)
35 printf("<%s> is acceptable.n",str);
36 else printf("<%s> is not acceptable.n",str);
37 }
38 return 0;
39 }
- finecms指定从第几篇文章开始调用5条记录,并调用文章所在栏目
- finecms如何调用多个栏目的子栏目
- 从傅立叶变换到Gabor滤波器
- 三个小时学会wordpress模板制作
- The each() function is deprecated报错的解决方法
- 书接上文:薛定谔的猫是如何诞生的?
- docker源码分析(3)---镜像(1)
- k8s源码分析-----kubelet(8)pod管理
- 大会 | DiracNets:无需跳层连接的ResNet
- golang时间戳格式化与解析
- golang-net/http源码分析之http server
- 白话面向智能体编程(Agent Oriented Programmig, AOP)之四
- 用fpm来做rpm打包
- Nginx配置文件nginx.conf详解
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- CSS、CSS3知识点清单
- linux使用MAT分析dump文件
- RabbitMQ 自动创建队列/交换器/绑定
- SpringBoot 整合Shiro实现动态权限加载更新+Session共享+单点登录
- 又一个布局利器, CSS 伪类 :placeholder-shown
- 聊聊微前端的原理和实践
- javax.el.PropertyNotFoundException: Property 'XXX' not found on type xx.xx.xx.xx(实体类具体路径)
- java基础知识点总结
- Ajax详解(拓展:利用Ajax实现用户名的校验)
- Maven学习笔记
- com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout 的解决
- 基于VSFTPD技术与KindEditor的简单案例
- Linux下安装JDK1.8、Tomcat、以及MySQL详细介绍(附软件分享)
- Nginx技术(附软件分享)
- (必考)关于JS中this关键字的说法,下面错误的是?