Codeforces Round #378 (Div. 2)A.Grasshopper And the String【水题】模拟

来源:互联网 发布:linux 多进程 信号 编辑:程序博客网 时间:2024/05/17 09:12

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

题目大意:

一个虫子从起点为0的位子,要跳到n+1的位子,而且他下一步跳到的位子如果之后的位子中有AEIOUY这些字母,就跳到这个位子。

问这个过程最远会跳多远。


思路:


简单题模拟即可,注意如果字符串中没有AEIOUY,那么我们直接从0跳到n+1;


Ac代码:

#include<stdio.h>#include<iostream>#include<string.h>using namespace std;char a[10000];int main(){    while(~scanf("%s",a+1))    {        int output=0;        int n=strlen(a+1);        int pre=0;        for(int i=1;i<=n;i++)        {            if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'||a[i]=='Y')            {                output=max(output,i-pre);                pre=i;            }        }        output=max(output,n+1-pre);        printf("%d\n",output);    }}






0 0
原创粉丝点击