hdu-5578 Friendship of Frog(暴力)】的更多相关文章

Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5578 Description N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance betwee…
Problem Description N frogs . Two frogs are friends if they come from the same country. The closest friends are a pair of friends with the minimum distance. Help us find that distance. Input First line contains an integer T, which indicates the numbe…
题意:给定一行字符串(都是小写字母),每一个字符都代表一只青蛙以及其国籍,若字符串中出现两个字符相同,则这两个字符所代表的青蛙来自同一国度,可称之为好朋友. 现在需要找到距离最近的好朋友并输出他们的距离. 思路:建立一个map映射表,映射关系为:字符<->字符所在字符串的位置,从字符串头部到尾部依次进行扫描,每扫到一个字符,可以找一找map表中有没有出现该字符,若没出现过则在 表中建立这个字符的关系,若map表中有该字符的记录,那么说明当前字符串代表的青蛙找到了一个朋友,可以计算他与朋友的距离…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5578 Friendship of Frog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 556    Accepted Submission(s): 355 Problem Description N frogs from differe…
Friendship of Frog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 135    Accepted Submission(s): 106 Problem Description N frogs from different countries are standing in a line. Each country i…
其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^{min(n,k)}\lfloor\frac{k}{i}\rfloor i$ /** @Date : 2017-09-21 19:55:31 * @FileName: HDU 2620 分块底数优化 暴力.cpp * @Platform: Windows * @Author : Lweleth (SoungE…
题 题意 求相同字母最近距离 分析 用数组保存各个字母最后出现的位置,维护最小距离. 代码 #include <cstdio> int c[30],n,p,a,minl; char ch; int main(){ scanf("%d ",&n); for(int i=1;i<=n;i++){ for(int j=0;j<27;j++)c[j]=0; p=1;minl=2000; while((ch=getchar())!='\n'){ a=ch-'a';…
YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5277 Description YJC是个老火车小司机.一个晚上,他仰望天空,星辰璀璨,他突然觉得,天空就像一个平面,而每一个星辰,就是平面中的一个点.他把这些点编号为1到n.这些点满足任意三点不共线.他把一些点用线段连起来了,但是任意两条线段不会在端点以外相交.如果一个点的集合中任意两个…
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geography teacher in the school.One day in his class,he marked N points in the map,the i-th point is at (Xi,Yi).He wonders,whether there is a tetrad (A,B,C,…
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 797    Accepted Submission(s): 284 Problem Description (From wikipedia) For binary…