[关闭]
@xunuo 2017-01-18T21:27:40.000000Z 字数 1613 阅读 1201

Grasshopper And the String

暴力

time limit per test 1 second memory limit per test256 megabytes

来源:codeforces 733 A Grasshopper And the String


Description

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

题意:

只能跳元音:A,E,I,O,U,和Y,输出跳的最多步数,跳过一个为一步

完整代码:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. #include<algorithm>
  5. using namespace std;
  6. char a[110],b[110],c[110];
  7. int main()
  8. {
  9. while(scanf("%s",a)!=EOF)
  10. {
  11. memset(a,sizeof(a),0);
  12. memset(b,sizeof(b),0);
  13. memset(c,sizeof(c),0);
  14. int l=strlen(a);
  15. int j=0;
  16. for(int i=0;i<l;i++)
  17. {
  18. if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'||a[i]=='Y')
  19. {
  20. b[j]=i;
  21. j++;
  22. }
  23. }
  24. if(j==0)
  25. {
  26. printf("%d\n",l+1);
  27. }
  28. else
  29. {
  30. int k=1;
  31. c[0]=b[0]+1;
  32. for(int i=1;i<j;i++)
  33. {
  34. c[k]=b[i]-b[i-1];
  35. k++;
  36. }
  37. c[k]=l-b[j-1];
  38. sort(c,c+k+1);
  39. printf("%d\n",c[k]);
  40. }
  41. }
  42. return 0;
  43. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注