A. Grasshopper And the String(CF ROUND 378 DIV2)
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 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
题目链接:http://codeforces.com/contest/733/problem/A
题目本意是让求他最大跳跃距离(最大跳跃距离是两个元音字母直接的距离,最后一个元音字母和结尾的距离,还有一种可能就是" B " 这样的情况)
WA了两发,
第一发没考虑到:
A 这样的数据
第二发没考虑到
B 这样的数据
AC代码:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
bool vowel( char i )
{
if(i == 'A' || i == 'E' || i== 'I' || i== 'O' || i== 'U' || i == 'Y' || i=='\0' ||i==' ' )
returntrue ;
returnfalse ;
}
int main()
{
strings;
cin>>s;
s='' + s ;
int_length = s.length() ;
intmax = 1 ;
for(int i = 0 ; i < _length ; i++)
{
if(vowel( s[i] ) )
{
for(int j = i+1; j<=_length ; j++)
{
if(vowel( s[j] ) )
{
if(j - i > max )
max= j-i;
break;
}
}
}
}
cout<< max << endl ;
return0 ;
}
A. Grasshopper And the String(CF ROUND 378 DIV2)的更多相关文章
- CF Round #580(div2)题解报告
CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- [CF Round #295 div2] C. DNA Alignment 【观察与思考0.0】
题目链接:C. DNA Alignment 题目大意就不写了,因为叙述会比较麻烦..还是直接看英文题面吧. 题目分析 经过观察与思考,可以发现,构造的串 T 的每一个字符都与给定串 S 的每一个字符匹 ...
- [CF Round #294 div2] E. A and B and Lecture Rooms 【树上倍增】
题目链接:E. A and B and Lecture Rooms 题目大意 给定一颗节点数10^5的树,有10^5个询问,每次询问树上到xi, yi这两个点距离相等的点有多少个. 题目分析 若 x= ...
- [CF Round #294 div2] D. A and B and Interesting Substrings 【Map】
题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求 ...
- A. Alyona and Numbers(CF ROUND 358 DIV2)
A. Alyona and Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- CF Round#436 div2
额,这次的题目其实挺智障的.所以通过这次比赛,我也发现了自己是一个智障.... 不说太多,说多是泪... A. Fair Game 题意:给你一个数组,看你能否把它均分为两个所有元素均相同的子数组. ...
- CF Round #569 Div2(contest1180)
比赛链接:http://codeforces.com/contest/1180 Problem A 题意:给出n,问方块数.看图理解... Solution: 找一找规律就可以了,发现方块数为2n*( ...
- CF Round #687 Div2 简要题解
题面 A 可以发现,最远的几个人一定是 \((1, 1), (1, m), (n, 1), (n, m)\) 中的一个,直接计算即可. B 注意到颜色数量很少,直接暴力枚举最终的颜色后模拟即可. C ...
随机推荐
- Swift3.0服务端开发(二) 静态文件添加、路由配置以及表单提交
今天博客中就来聊一下Perfect框架的静态文件的添加与访问,路由的配置以及表单的提交.虽然官网上有聊静态文件的访问的部分,但是在使用Perfect框架来访问静态文件时还是有些点需要注意的,这些关键点 ...
- easyui 个人使用心得之下拉列表
下拉框: 第一种:从数据库获取<input id="FlowType" name="FlowType" style="width: 245px; ...
- 根据字节码探讨java自增运算符的原理
public class Test { static int x, y; public static void main(String args[]) { x++; myMethod(); Syste ...
- 在egret中使用protobuf
原文章删除,重新使用MarkDown排版 在H5游戏领域,对于服务端与客户端的通信协议有一个选择,那就是使用protobuf.js.对于那些直接使用JavaScript开发的引擎而言,protobuf ...
- 当我们在谈论kmeans(3)
本系列意在长期连载分享,内容上可能也会有所删改: 因此如果转载,请务必保留源地址,非常感谢! 博客园:http://www.cnblogs.com/data-miner/(暂时公式显示有问题) ...
- H5与CS3权威下.18 and 19 选择器(1)
18章.CSS3概述 1.从前端技术的角度把互联网的发展分为三个阶段: (1)web1.0:HTML和CSS. (2)web2.0:Ajax,Javascript/DOM/异步数据请求. (3)web ...
- Docker集群实验环境布署--swarm【2 搭建本地镜像仓库】
在10.40.100.148上 # docker run -d -p 5000:5000 --restart=always --name docker-registry.venic.com - ...
- [读书笔记]telnet与http服务器一次直接对话
1.打开电脑telnet客户端应用 控制面板 >程序和功能 > 打开或者关闭windows功能 > telnet客户端 勾选,并确认. 2.执行telnet命令 a:cmd进入控制台 ...
- NYOJ-括号配对问题 <技巧性的非栈道法>
括号配对问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 现在,有一行括号序列,请你检查这行括号是否配对. 输入 第一行输入一个数N(0<N<=100) ...
- 从minist database(t10k-images-idx3-ubyte)中读取图片
matlab代码(亲测,可运行出来): % Matlab_Read_t10k-images_idx3.m % 用于读取MNIST数据集中t10k-images.idx3-ubyte文件并将其转换成bm ...