A. Grasshopper And the String

匿名 (未验证) 提交于 2019-12-03 00:27:02

One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump 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

AC代码(模拟题)

#include <iostream> #include <bits/stdc++.h> using namespace std;  int main() {     char s[120];     int n, i, h, b[120];     while(scanf("%s",s)!=EOF)     {      n = strlen(s);      int maxi = 0, d = 0;      for(i = 0;i<n;i++)      {       d++;       if(s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U'||s[i]=='Y')       {        if(maxi<d)        maxi = d;        d = 0;       }      }      d++;     if(d>maxi)      maxi = d;      printf("%d\n",maxi);     }     return 0; }

转载请标明出处:A. Grasshopper And the String
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!