codeforces733A.Grasshopper And the String

来源:互联网 发布:网站源码可以导出来吗 编辑:程序博客网 时间:2024/05/18 03:27

          
A. Grasshopper And the String
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimumjump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet.Jump ability is the maximum possible length of his jump.

Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.

The picture corresponds to the first example.

The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.

Input

The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.

Output

Print single integer a — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.

Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
这个题题意就是求元音到元音之间的最大长度,第一次没有A过,原因发现蚂蚁跳到字符末尾也会加一,所以忽略了最后如果长度最长的话就WA了,所以想到了从头开始计数,就避免了字符串末尾的计算。AC代码如下:
#include<iostream>#include<cstdio>using namespace std;int main(){char s[105];cin >> s;int t = 1,max=1;for (int i = 0; s[i] != '\0'; i++){if (s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O'|| s[i] == 'U' || s[i] == 'Y'){t = 1;continue;}t++;if (t > max)  max = t;}printf("%d\n", max);return 0;}


0 0
原创粉丝点击