C - Haiku
Problem description
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words.
To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: "a", "e", "i", "o" and "u".
Three phases from a certain poem are given. Determine whether it is haiku or not.
Input
The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification.
Output
Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).
Examples
Input
on codeforces
beta round is running
a rustling of keys
Output
YES
Input
how many gallons
of edo s rain did you drink
cuckoo
Output
NO
解题思路:只要符合俳句(由“五-七-五”,共十七字音组成,题目要求这些字音是必须都是元音字母)就输出"YES",否则输出"NO",java水过!
AC代码:
import java.util.Scanner;
public class Main {
final static char[] obk={'a','e','i','o','u'};
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String[] s1=scan.nextLine().split(" ");
String[] s2=scan.nextLine().split(" ");
String[] s3=scan.nextLine().split(" ");
int n1=r(s1,0),n2=r(s2,0),n3=r(s3,0);
if(n1==5&&n2==7&&n3==5)System.out.println("YES");
else System.out.println("NO");
}
public static int r(String[] s,int n){
for(int i=0;i<s.length;++i){
for(int j=0;j<s[i].length();++j){
for(int k=0;k<5;++k)
if(s[i].charAt(j)==obk[k])n++;
}
}
return n;
}
}
C - Haiku的更多相关文章
- 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition) (水水)
题目链接:http://abc042.contest.atcoder.jp/tasks/abc042_a Time limit : 2sec / Memory limit : 256MB Score ...
- [Arc058E] Iroha and Haiku
[Arc058E] Iroha and Haiku 题目大意 问有多少\(n\)个数的正整数序列,每个数在\([1,10]\)之间,满足存在\(x,y,z,w\)使得\(x\to y-1,y\to z ...
- 水题 Codeforces Beta Round #70 (Div. 2) A. Haiku
题目传送门 /* 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 下午网速巨慢:( */ #include <cstdio> #include <cstring> ...
- Solution -「ARC 058C」「AT 1975」Iroha and Haiku
\(\mathcal{Description}\) Link. 称一个正整数序列为"俳(pái)句",当且仅当序列中存在连续一段和为 \(x\),紧接着连续一段和为 \(y ...
- Libpci库的调用
这几天发现在Redhat AS6.5 X86_64下用outl(index, 0xcf8)和inl(0xcfc)下读取PCIe配置空间是系统有时性的会hang, 于是去寻找解决方案,首先想到的是用/d ...
- iOS 资源大全
这是个精心编排的列表,它包含了优秀的 iOS 框架.库.教程.XCode 插件.组件等等. 这个列表分为以下几个部分:框架( Frameworks ).组件( Components ).测试( Tes ...
- 盘点国内程序员不常用的热门iOS第三方库:看完,还敢自称”精通iOS开发”吗?【转载】
综合github上各个项目的关注度与具体使用情况,涵盖功能,UI,数据库,自动化测试,编程工具等类型,看完,还敢自称”精通iOS开发”吗? https://github.com/syedhali/EZ ...
- IOS中文版资源库
Swift 语言写成的项目会被标记为 ★ ,AppleWatch 的项目则会被标记为 ▲. [转自]https://github.com/jobbole/awesome-ios-cn#librari ...
- github上所有大于800 star OC框架
https://github.com/XCGit/awesome-objc-frameworks#awesome-objc-frameworks awesome-objc-frameworks ID ...
随机推荐
- zTree 模糊搜索
/** * 搜索树,高亮显示并展示[模糊匹配搜索条件的节点s] * @param treeId * @param searchConditionId 搜索条件Id */ function search ...
- Lua中返回值的丢失问题
Lua中返回值的丢失问题 -- 如果函数调用所得的多个返回值是另外一个函数的最后一个参数,或者是多指派表达式中的最后一个参数时,所有返回值将被传入或使用. -- 否则只有第一个返回值被使用或指定. T ...
- flask之配置文件的加载和动态url的使用
七行代码实现一个flask app from flask import Flask app = Flask(__name__) @app.route('/') def helloworld(): re ...
- 五、Scrapy中Item Pipeline的用法
本文转载自以下链接: https://scrapy-chs.readthedocs.io/zh_CN/latest/topics/item-pipeline.html https://doc.scra ...
- Vim 基本操作
Vim 基本操作 vim的模式 命令模式 2. 编辑模式 3. 尾行模式 编辑 i : 插入 光标所在位置 a : 插入 光标所在位置的下一个位置 o : 插入 光标所在位置的下一行插入新行 O : ...
- Python - 面对对象(进阶)
目录 Python - 面对对象(进阶) 类的成员 一. 字段 二. 方法 三. 属性 类的修饰符 类的特殊成员 Python - 面对对象(进阶) 类的成员 一. 字段 字段包括:普通字段和静态字段 ...
- Codeforces 263C. Appleman and Toastman
C. Appleman and Toastman time limit per test 2 seconds memory limit per test 256 megabytes input ...
- 清北学堂模拟赛d3t1 a
[问题描述]你是能看到第一题的friends呢.——hja 怎么快速记单词呢?也许把单词分类再记单词是个不错的选择.何大爷给出了一种分单词的方法,何大爷认为两个单词是同一类的当这两个单词的各个字母的个 ...
- springboot优雅关机
Spring boot 2.0 之优雅停机 rabbitGYK 关注 2018.05.20 18:41* 字数 1794 阅读 2638评论 0喜欢 22 spring boot 框架在生产环境使用 ...
- HTML5:判断浏览器是否支持date类型
在某些情况下,我们需要判断当前浏览器是否支持date类型,如果支持的话,可以让用户用原生的datepicker来选取日期.如果不支持,则我们需要用自己实现的datepicker类库,来提供给用户. 在 ...