HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
Easier Done Than Said?
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.
a
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end
<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:不能连续两个同样的字母,除非ee或oo
直接推断。代码例如以下:
#include<cstdio>
#include<cstring>
int yuanfu[27]={0};
bool yuan(char s[]){//推断有无元音字字母
for(int i=0;i<strlen(s);i++)
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
return true;
return false;
}
bool sanlian(char s[]){//推断有无三个连续的元音或辅音字母
if(strlen(s)<3) return true;
for(int i=0;i<strlen(s)-2;i++)
if(yuanfu[s[i]-'a']==yuanfu[s[i+1]-'a']&&yuanfu[s[i+1]-'a']==yuanfu[s[i+2]-'a'])
return false;
return true;
}
bool erlian(char s[]){//推断有无两个连续同样非ee或oo字母
if(strlen(s)<2) return true;
for(int i=0;i<strlen(s)-1;i++)
if(s[i]==s[i+1]&&!(s[i]=='e'||s[i]=='o'))
return false;
return true;
}
int main(){
char s[110];
yuanfu[0]=yuanfu[4]=yuanfu[8]=yuanfu[14]=yuanfu[20]=1;
while(scanf("%s",s)!=EOF&&strcmp(s,"end")){
if(!yuan(s)) printf("<%s> is not acceptable.\n",s);
else if(!sanlian(s)) printf("<%s> is not acceptable.\n",s);
else if(!erlian(s)) printf("<%s> is not acceptable.\n",s);
else printf("<%s> is acceptable.\n",s);
}
return 0;
}
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
HDU 1039.Easier Done Than Said?【字符串处理】【8月24】的更多相关文章
- hdu 1039 Easier Done Than Said? 字符串
Easier Done Than Said? Time Limi ...
- HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)
Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy ...
- HDU 1039.Easier Done Than Said?-条件判断字符串
Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- 题解报告:hdu 1039 Easier Done Than Said?
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 Problem Description Password security is a trick ...
- HDU 1039 -Easier Done Than Said?
水水的 #include <iostream> #include <cstring> using namespace std; ]; bool flag; int vol,v2 ...
- HDU 1042.N!【高精度乘法】【8月24】
N! Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N ...
- 字符串 HDU 1039
规则: 1.必须至少包含一个元音字母.a e i o u 2.不能包含三个连续元音或者连续辅音字母. 3.不能包含两个连续字母,除了'ee'和'oo'. PS:字母个数(1<= N <=2 ...
- HDU 1039(字符串判断 **)
题意是检查一个字符串是否满足三个条件: 一.至少有一个元音字母.二.不能出现三个连续的元音或三个连续的辅音.三.除了 ee 和 oo 外不能出现两个连续相同字母. 若三个条件都能满足,该字符串满足条件 ...
- hdu 5469 Antonidas(树的分治+字符串hashOR搜索+剪枝)
题目链接:hdu 5469 Antonidas 题意: 给你一颗树,每个节点有一个字符,现在给你一个字符串S,问你是否能在树上找到两个节点u,v,使得u到v的最短路径构成的字符串恰好为S. 题解: 这 ...
随机推荐
- VUE:渐进式JavaScript框架(小白自学)
VUE:渐进式JavaScript框架 一.官网 英文 https://vuejs.org/ 中文 https://cn.vuejs.org/ 二:渐进式 即有一个核心库,在需要的时候再逐渐添加插件的 ...
- Vue常用的GitHub项目
Vue常用的GitHub项目(Demo案例) 应用实例 https://github.com/pagekit/pa... pagekit-轻量级的CMS建站系统 https://github.com/ ...
- nutch+hadoop 配置使用
nutch+hadoop 配置使用 配置nutch+hadoop 1,下载nutch.如果不需要特别开发hadoop,则不需要下载hadoop.因为nutch里面带了hadoop core包以及相关配 ...
- 洛谷—— P1640 [SCOI2010]连续攻击游戏
https://www.luogu.org/problem/show?pid=1640 题目描述 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1, ...
- Android Touch事件传递机制全面解析(从WMS到View树)
转眼间近一年没更新博客了,工作一忙起来.非常难有时间来写博客了,因为如今也在从事Android开发相关的工作,因此以后的博文也会很多其它地专注于这一块. 这篇文章准备从源代码层面为大家带来Touch事 ...
- [React] Integration test a React component that consumes a Render Prop
In this lesson, I use Enzyme and Jest's Snapshot functionality to write an integration test for a co ...
- linux openssl加密文件
openssl 支持的加密算法 -aes-128-cbc -aes-128-cfb -aes-128-cfb1 -aes-128-cfb8 -aes-128-ecb -aes-128-ofb -aes ...
- cocos2d_x_03_经常使用类的使用_事件_画图
一.TextFieldTTF输入框的使用 #pragma mark - 自己定义方法 // 自己定义方法,加入一个 TextField void TextFieldScene::addOneTextF ...
- javascript 获取指定范围随机数
<script type="text/javascript"> function GetRandomNum(Min,Max){ var Range = Max - Mi ...
- OKHttp使用简介
现在android网络方面的第三方库很多,volley,Retrofit,OKHttp等,各有各自的特点,这边博客就来简单介绍下如何使用OKHttp. 梗概 OKHttp是一款高效的HTTP客户端,支 ...