Haiku

#生成式 AI 的发展方向,是 Chat 还是 Agent?#

题目描述

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.

输入格式

The input data consists of three lines. The length of each line is between 11 and 100100 , 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.

输出格式

Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).

题意翻译

题目大意:

Haiku是日本传统诗歌的一种流派。

这种诗歌由三个短句组成,共有17个音节。

其中,第一个短句有5个音节,第二个短句有7个音节,第三个短句有5个音节。

为了简化问题,短句的音节数视为这个短句中的元音字母数。

只有以下字母被视为元音字母:“a”,“e”,“i”,“o”和“u”。

任务:给出一首诗,判断它是不是Haiku。

INPUT:

输入数据由三行组成。每行长度在1~100之间,由小写英文字母组成。允许有空格前缀或空格后缀。每个短句中至少有一个小写字母。

OUTPUT:

如果这首诗是Haiku,输出“YES”,否则输出“NO”。

输入输出样例

输入 #1复制

on  codeforces 
beta round is running
   a rustling of keys 

输出 #1复制

YES

输入 #2复制

how many gallons
of edo s rain did you drink
                                cuckoo

输出 #2复制

NO

题目大意:给你三个串,如果第一个串和第三个串中的元音字母数量等于5个,并且第二个串中的元音字母数量等于7个,那么输出 YES,否则输出 NO

因为 允许有空格前缀或空格后缀,所以要用 getline 读入字符串。读入方法:

getline(cin, 字符串名称)

代码如下:

#include<bits/stdc++.h>
using namespace std;
string a,b,c;
int main() {
	int cnt1,cnt2,cnt3,i,n1,n2,n3;
	getline(cin,a);
	n1=a.size();
	getline(cin,b);
	n2=b.size();
	getline(cin,c);
	n3=c.size();
	cnt1=cnt2=cnt3=0;
	for(i=0;i<n1;i++)
		if(a[i]=='a'||a[i]=='o'||a[i]=='e'||a[i]=='u'||a[i]=='i') cnt1++;
	for(i=0;i<n2;i++)
		if(b[i]=='a'||b[i]=='o'||b[i]=='e'||b[i]=='u'||b[i]=='i') cnt2++;
	for(i=0;i<n3;i++)
		if(c[i]=='a'||c[i]=='o'||c[i]=='e'||c[i]=='u'||c[i]=='i') cnt3++;
	if (cnt1==5&&cnt2==7&&cnt3==5) cout<<"YES";
	else cout<<"NO";
    return 0;
}

拜拜! 

  • 15
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值