NYOJ Grasshopper And the String
来源:互联网 发布:人工智能手机芯片 编辑:程序博客网 时间:2024/06/06 00:00
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 1to the value of his jump ability.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
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.
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.
ABABBBACFEYUKOTT
4
AAA
某日,一只蚂蚱来到了一片字母草地。草地由n个大写字母组成。蚂蚱一开始在草地的最左边(位置0),它要去往草地的最右边(位置n+1)。这只蚂蚱只在元音字母上跳跃(起点和终点除外)。定义这只蚂蚱的跳跃能力为它一次跳跃能跳过的最远距离。
试问,若要让这只蚂蚱顺利到达终点,蚂蚱的跳跃能力最小是多少?下图是样例1的参考图:
元音字母有: 'a', 'E', 'I', 'O', 'U','Y'.
一行一个字符串s,只有大写字母,描述这个草地。长度小于 1000。
输出一个整数,表示这只蚂蚱最小跳跃能力。
ABABBBACFEYUKOTT
AAA
4
1
无
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char a[1010];int main(){ memset(a,0,sizeof(a)); while(~scanf("%s",a)) { int b[1010]={0},c[1010]={0},d=0,k=1; int len=strlen(a); for(int i=0; i<len; i++) { if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'||a[i]=='Y') b[d++]=i; } c[0]=b[0]+1; for(int i=1; i<d; i++) c[k++]=b[i]-b[i-1]; c[k++]=len-b[d-1]; sort(c,c+k); if(d!=0) printf("%d\n",c[k-1]); if(d==0) printf("%d\n",len+1); } return 0;}
- NYOJ Grasshopper And the String
- Grasshopper And the String
- Grasshopper And the String
- codeforces733A.Grasshopper And the String
- A. Grasshopper And the String
- A. Grasshopper And the String
- 【codeforces】Grasshopper And the String(div2A)
- Codeforces 733A Grasshopper And the String
- codeforces--733A. Grasshopper And the String
- CodeForces 733A - Grasshopper And the String
- 733A Grasshopper And the String
- Codeforces 733A Grasshopper And the String
- 【非常高%】【codeforces 733A】Grasshopper And the String
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #378 (Div. 2) A. Grasshopper And the String
- codeforces#378 Div.2 A. Grasshopper And the String
- [codeforces] A. Grasshopper And the String 简单模拟
- 733A Grasshopper And the String codeforces(水题)
- shell 命令集合
- 根据先序和中序序列求二叉树
- redis常用命令讲解
- TensorFlow .tfrecords训练文件生成、使用
- 运营商卡名字多语言显示
- NYOJ Grasshopper And the String
- 使用 electron-vue 构建你的桌面应用
- 第二周
- 关于ssh为什么要在DAO层实现类中继承HibernateDaoSupport的原因
- 第三期 利用已经训练的神经网络进行图像识别 《显卡就是开发板》
- 手与大脑的距离决定了现实与理想的相似度
- (error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on d
- 什么是脏读,不可重复读,幻读
- 前端性能优化