HDU 1039 判断字符串的合法性

(一)利用Python实现数据集读取,Python基本文件操作介绍 机器学习是计算机对大量数据的分析过程,在机器学习的实际项目中,通常都需要准备数据集,数据集通常包含的数据数量是庞大的。例如,在处理计算机视觉领域的项目时,每一张图片都是一个单独的文件,为了提高模型训练的效果,图片数量通常会比较多,因此需要合理且高效的操作将所有的图片数据读取。本篇旨在介绍如何用Python对海量文件进行遍历,也是机器学习实践的第一步。......... 阅读详情

HDU 1039

Easier Done Than Said?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11480    Accepted Submission(s): 5567


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
 

Recommend
We have carefully selected several similar problems for you:   1062  1073  1043  1088  1113 

 

水

别人的代码:

#include <iostream>
#include <string>

using namespace std;

bool is_vowel(char x)
{
    if(x=='a'||x=='e'||x=='u'||x=='i'||x=='o') return 1;
    else return 0;
}
int main()
{
    string a;
    while(cin>>a)
    {
        if(a=="end") break;
        int len=a.size();
        int ans=0;
        for(int i=0;i<len;i++)
            if(is_vowel(a[i]))
            {
                ans=1;
                break;
            }
        for(int i=1;i<len&&ans;i++)
            if(a[i]==a[i-1]&&a[i]!='e'&&a[i]!='o')
            ans=0;
        for(int i=2;i<len;i++)
        {
            if(is_vowel(a[i])&&is_vowel(a[i-1])&&is_vowel(a[i-2]))
                ans=0;
            if(!is_vowel(a[i])&&!is_vowel(a[i-1])&&!is_vowel(a[i-2]))
                ans=0;
        }
        if(ans) cout<<'<'<<a<<"> is acceptable."<<endl;
        else cout<<'<'<<a<<"> is not acceptable."<<endl;
    }
}


大地坐标系与经纬度转换(一):大地坐标系简介 一、大地坐标系 大地坐标系是大地测量中以参考椭球面为基准面建立起来的坐标系。地面点的位置用大地经度、大地纬度和大地高度表示。 二、地心坐标系 ... 阅读详情

相关推荐

基于KiCad的STM32最小系统设计实战案例(含PCB布线)

手把手带你用KiCad完成STM32最小系统设计,涵盖原理图绘制、封装匹配、规则约束设置及关键信号PCB布线技巧;全程基于开源EDA工具KiCad,强调实操细节与常见坑点规避。

weixin_42452483的博客 368

HDU1039(字符串水题)

题目简述: 判断字符串是否同时满足: 1:有元音字母 2:不能三个连续元音或辅音 3.不能连续两个相同的字母,除非ee或oo end终止输入 AC代码: #include&lt;iostream&gt; #include&lt;string&gt; using namespace std; int yuan(char c) {     if (c == 'a' || c == 'e'...

weirdo_coder的博客 448

工具变量三连检全解析:识别不足、弱工具变量与过度识别

因果推断是实证研究的核心追求,而工具变量法则是在内生性困扰下获取可信因果效应的关键武器。在实际操作中,研究者常借助Stata软件执行两阶段最小二乘估计,但面对输出结果中繁杂的统计量,如何解读识别不足检验、弱工具变量诊断与过度识别限制检验,成为区分严谨实证与“跑回归”的分水岭。理解这些检验的统计学原理:识别不足检验通过LM统计量考察工具变量与内生变量的相关性;弱工具变量诊断借助CDW统计量评估第一阶段解释力;过度识别检验利用Hansen J统计量判断多余工具变量的外生性。掌握它们在异方差、聚类稳健标准误下的适

weixin_30119911的博客 268

HDU(1039):Easier Done Than Said?

题目: Problem Description  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 w...

Zayn123的博客 362

C#海康威视摄像头控制,将IntPtr转换成Bitmap图片

C#通过skd控制海康威视摄像头,获取bitmap格式图片

ReflexMechanism的博客 6593

学Simulink——基于Simulink的输入-输出线性化精确转矩控制

本文详细介绍了基于Simulink的永磁同步电机(PMSM)输入-输出线性化(IOL)精确转矩控制方法。针对传统解耦控制在非线性转矩特性下的局限性,提出通过精确反馈线性化实现转矩指令与实际转矩的严格线性关系。文章系统阐述了IOL原理、PMSM控制器推导过程,并提供了完整的Simulink建模步骤,包括电机模型搭建、IOL控制器实现和闭环系统构建。通过仿真对比验证了IOL方法在转矩跟踪精度、动态响应和参数鲁棒性方面的显著优势,最后讨论了工程实现要点和扩展应用方向。该方法为高性能伺服系统开发提供了有效解决方案。

amy_mhd的博客 63

字符串处理--HDU第1039解题报告

题目链接 要满足三个条件,所以最好一点写成一个函数,这样做就不会像全部代码都在main()函数中写一样,要考虑很多细节。 这三个函数都很简单。(我再也不用划译了,条件二给翻译错了,哎,加强英语吧) 下面是代码: #include #include using namespace std; bool rule_one(string &str); bool rule_two(s

剑行earth 529

Unity如何实现数字人口型同步

SALSA LipSync v2是一款实时唇音同步系统,无需音素映射即可根据音频自动生成口型动画。系统提供三大核心功能:基于音频波形分析的智能口型同步、EmoteR表情随机化工具以及Eyes眼睛/头部追踪系统。配置流程简单快捷,只需导入模型后通过一键配置完成基础设置,再添加A/E/I/O/U等基本口型混合变形即可实现基础功能。进阶功能支持表情池管理(手动/随机/强调/重复触发)和眼部动作配置(骨骼旋转或混合变形)。系统支持三种输入方式:本地音频文件分析、麦克风实时输入和文本转语音,为数字人角色提供完整的表情

TxNet 768

HDU 1039(字符串判断 **)

题意是检查一个字符串是否满足三个条件: 一、至少有一个元音字母。二、不能出现三个连续的元音或三个连续的辅音。三、除了 ee 和 oo 外不能出现两个连续相同字母。 若三个条件都能满足,该字符串满足条件,有一个条件不满足则该字符串不满足条件。 但是这道题的数据......一定有元音字母,长度一定不少于 3。省去很多麻烦...... 代码如下: 1 #include &l...

b338865802883204的博客 230

【GameFramework框架内置模块】9、有限状态机(FSM)

这篇文章分享FSM有限状态机,了解过StarForce源码的同学相比都比较了解,GameFramework框架给我们抽象了一个Procedure流程的概念。这个Procedure流程可以方便的处理我们游戏从启动到游戏的各个流程阶段的处理逻辑,实现的核心就是FSM状态机,内部的Procedure流程就是不同的FsmState状态。接下来,就是FSM有限状态机的教程了。有限状态机(Finite-state machine,FSM)

CSDN博客专家,Unity3D高级软件工程师,《Unity 3D从入门到实战》作者。 2539

DCDC电路断电时放电波形发生震荡和电压跳变问题,如何解决?

DCDC电路断电时放电波形发生震荡和电压跳变问题: 做的一个项目需要用单片机ADC采集电压,要让单片机感应到电压降到3.1V开始往FLASH里存数据,单片机2.4V基本上就工作不了,(根据单片机手册的,擦写的时间在40mS在左右)所以3.1V降到2.4V的时间必须要大于40mS岁以上,在单片机VCC处加了一个100nF的电容,理论仿真下来150mS左右发现存不进去,用示波器抓了一下波形,发现放电时震荡很严重,实际3.1V到2.4V时间只有10ms左右,这个肯定存不进去; 请教师傅说是应该时前级DCDC开关电

**My Coding Family** 1996

HDU--1039:Easier Done Than Said? (字符串)

2. 解题代码:

酒酿小圆子呀~ 763

ArcMap|使用模型构建器将kml文件批量转图层

参考:https://www.jianshu.com/p/6de18f846024 第一步:打开模型构建器,拖入kml转图层工具 第二步:插入文件迭代器 第三步:双击“迭代文件”,选择kml所在文件夹 第四步:将“File.kml”与“KML转图层”连接,点击“输入KML文件” 第五步:双击“KML转图层”,更改输出位置,输出数据名称改为%名称% 第六步:运行模型 得到结果: ...

个人学习笔记 3607

hdu 1039

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1039 题意:判断密码是否可行。满足三个条件:1.至少一个元音字母。2.连续三个字母不能同时为元音或辅音。3.连续两个字母不能相同,但是不包括"ee"和"oo"。 mark:无。 代码: #include <stdio.h> #include <string.h> ...

weixin_30702413的博客 113

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

HDOJ  1039   Easier Done Than Sa…

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1039 只要题目读清楚, 1:至少一个元音字母, 2:不能有连续三个的元音或辅音字母 3:不能有连续相同的两个字母,除(ee,oo)外....... #include #include using namespace std; inline int sew(char c) {     if(c=='a'

stven_king的专栏 494

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU 1049-Easier Done Than Said?

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-ge

别止的博客 417

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

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): 5309    Accepted Submission(s): 2681 Problem Description Passwor

wenlovingliu的专栏 762

HDU1039:Easier Done Than Said?

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-ge

ACM!荣耀之路! 4047

HDU1039 Easier Done Than Said?(java)

HDU1039 Easier Done Than Said?(java)

昔往矣今何在 535

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): 14313 Accepted Submission(s): 6934 Problem Description Password s

暗淡的时光 788

杭电OJ——1039 Easier Done Than Said?(水题)

Easier Done Than Said? 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. Som

李树花开,风中摇曳 2366

hdu1039 java正则表达式解法

Easier Done Than Said? 题意就是测试一段字符串是否满足下面三个条件: (1)至少含有一个元音(a、e、i、o、u) (2)不能连续三个是元音,也不能连续三个是非元音 (3)不能有连续两个字母是相同的,但是ee和oo除外 默认情况下,给出的字符串只含有小写字母。 当然这道题目用c++,解起来也不是很困难的,这次用java主要是练习正则表达式。 java代码...

weixin_30551947的博客 186

HDOJ 1039 Easier Done Than Said? 简单的字符串处理

#include"stdio.h" #include"string.h" int vo(char *psw,int i) {return (psw[i]=='a'||psw[i]=='e'||psw[i]=='i'||psw[i]=='o'||psw[i]=='u');} int main() { char psw[21],ans[2][15]={{"not accept

Kizuki 474

hdoj 1039

#include #include #include using namespace std; #define MAX 30 char password[MAX]; int isVowel(char c) { if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') { return 1; } return 0; }

longyuan20102011的专栏 929
上一篇: HDU 1038 简单计算
下一篇: HDU 1040 排序
DT2131
博客等级 码龄11年 32粉丝 301原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值