RePorridge

Nothing change but our heart

题目描述:
输入一个字符串,求出其中最长的回文子串。子串的含义是:在原串连续出现的字符串片段。回文的含义是:正着看和倒着看是相同的,如abba和abbebba。在判断是要求忽略所有的标点和空格,且忽略大小写,但输出时按原样输出(首尾不要输出多余的字符串)。输入字符串长度大于等于1小于等于5000,且单独占一行(如果有多组答案,输出第一组)。

样例输入: Confuciuss say: Madam, I'm Adam.
样例输出: Madam, I'm Adam

其中,回文的意思是指字母构成回文,所以处理的时候需要把除字母外的符号先忽略掉。可以用cctype或者ctype.h头文件中的isalpha函数判断其是否为字母。

其次,也无需考虑字母的大小写,于是可用上述头文件的toupper或者tolower将其中的字符统一转换成大写或小写。

huiwen.cpp
posted @ 2013-08-30 11:23 Porridge 阅读(497) | 评论 (0)编辑 收藏
找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合。输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数。具体格式见样例输出(为了便于观察,竖式中的空格改用小数点显示,但你的程序应该输出空格,而非小数点)。
样例输入:2357
样例输出:
<1>
..775
X..33
-----
.2325
2325.
-----
25575
The number of solutions = 1

down.cpp
posted @ 2013-08-29 21:47 Porridge 阅读(516) | 评论 (0)编辑 收藏
Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 60483 Accepted Submission(s): 22247


Problem Description
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you.


Input
Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.


Output
For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.


Sample Input
5
green
red
blue
red
red
3
pink
orange
pink
0


Sample Output
red
pink

题意:给你很多字符串,让你找到数量最多的字符串,而且保证数量最多的字符串是唯一的
本题其实直接利用string读入然后直接利用string可比较大小排序后遍历每一个内容并记录每个对应项的个数然后按顺序从大到小把对应项输出就行了。
注意:题目中所指的气球不仅仅是气球,其实是对应的字符串。你把各种颜色列出来是没用的。

HDU1004.cpp
posted @ 2013-06-12 19:42 Porridge 阅读(634) | 评论 (0)编辑 收藏
仅列出标题
共3页: 1 2 3 

导航

<2024年10月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜