zoukankan      html  css  js  c++  java
  • C

    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代码:
     1 import java.util.Scanner;
     2 public class Main {
     3     final static char[] obk={'a','e','i','o','u'}; 
     4     public static void main(String[] args) {
     5         Scanner scan = new Scanner(System.in);
     6         String[] s1=scan.nextLine().split(" ");
     7         String[] s2=scan.nextLine().split(" ");
     8         String[] s3=scan.nextLine().split(" ");
     9         int n1=r(s1,0),n2=r(s2,0),n3=r(s3,0);
    10         if(n1==5&&n2==7&&n3==5)System.out.println("YES");
    11         else System.out.println("NO");
    12     }
    13     public static int r(String[] s,int n){
    14         for(int i=0;i<s.length;++i){
    15             for(int j=0;j<s[i].length();++j){
    16                 for(int k=0;k<5;++k)
    17                     if(s[i].charAt(j)==obk[k])n++;
    18             }    
    19         }
    20         return n;
    21     }
    22 }
    
    
  • 相关阅读:
    云端开发,云端部署
    Chrome下的Page Speed使用
    Linux的到来
    NoSQL 之 Morphia 操作 MongoDB
    qTip2
    在.NET下使用Task Parallel Library提高程序性能
    WCF REST系列文章汇总
    Google工具pagespeed使用教程
    从零开始系统深入学习android
    如何优化一个网站使之提高访问速度
  • 原文地址:https://www.cnblogs.com/acgoto/p/9180924.html
Copyright © 2011-2022 走看看