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 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.
Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(x,y) for(int j=x;j<y;j++)
using namespace std;
const int maxn =1000+5;
char s[maxn];
int a[5];
int main()
{
rep(0,3)
{
a[j]=0;
gets(s);
for(int i=0;s[i];i++)
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
a[j]++;
}
if(a[0]==5&&a[1]==7&&a[2]==5) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
The Easter Rabbit laid n eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
- Each of the seven colors should be used to paint at least one egg.
- Any four eggs lying sequentially should be painted different colors.
Help the Easter Rabbit paint the eggs in the required manner. We know that it is always possible.
The only line contains an integer n — the amount of eggs (7 ≤ n ≤ 100).
Print one line consisting of n characters. The i-th character should describe the color of the i-th egg in the order they lie in the circle. The colors should be represented as follows: "R" stands for red, "O" stands for orange, "Y" stands for yellow, "G" stands for green, "B" stands for blue, "I" stands for indigo, "V" stands for violet.
If there are several answers, print any of them.
#include <cstdio>
#include <iostream>
using namespace std;
char s[7]={'R','O','Y','G','B','I','V'};
int main()
{
int n;
scanf("%d",&n);
if(n%7==0)
{
int t=n/7;
while(t--)
{
for(int i=0;i<7;i++)
printf("%c",s[i]);
}
return 0;
}
int t=n/7;
while(t--)
{
for(int i=0;i<7;i++)
printf("%c",s[i]);
}
t=n%7;
for(int i=3;i<7&&t;i++,t--)//只打后面4个防止后行首3个出现重复情况
printf("%c",s[i]);
if(t)
{
for(int i=3;i<7&&t;i++,t--)
printf("%c",s[i]);
}
return 0;
}
Two beavers, Timur and Marsel, play the following game.
There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of each one is expressed by an integer and is no less than k meters. Each resulting part is also a log which can be gnawed in future by any beaver. The beaver that can't make a move loses. Thus, the other beaver wins.
Timur makes the first move. The players play in the optimal way. Determine the winner.
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 109).
Print "Timur", if Timur wins, or "Marsel", if Marsel wins. You should print everything without the quotes.
1 15 4
Timur
4 9 5
Marsel
In the first sample the beavers only have one log, of 15 meters in length. Timur moves first. The only move he can do is to split the log into 3 parts each 5 meters in length. Then Marsel moves but he can't split any of the resulting logs, as k = 4. Thus, the winner is Timur.
In the second example the beavers have 4 logs 9 meters in length. Timur can't split any of them, so that the resulting parts possessed the length of not less than 5 meters, that's why he loses instantly.
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
if(n%2==0)//n为偶数时Marsel只要每次重复Timur的动作即可
{
cout<<"Marsel"<<endl;
return 0;
}
bool flag=false;
for(int i=2;i*i<=m;i++)
if(m%i==0&&(i>=k||m/i>=k))//注意题意为长度<k的不能出现,这里找到m能分成的长度大于等于K的最小值t,然后剩下的转换为先手必败局面
flag=true;
if(flag) cout<<"Timur"<<endl;
else if(k==1&&m>1) cout<<"Timur"<<endl; //k==1且m>1时先手必胜
else cout<<"Marsel"<<endl;
return 0;
}