hdu 1004 Let the Balloon Rise
来源:互联网 发布:手机淘宝链接哪里找 编辑:程序博客网 时间:2024/06/05 20:37
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 55315 Accepted Submission(s): 20076
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.
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.
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
5greenredblueredred3pinkorangepink0
Sample Output
redpink
Author
WU, Jiazhi
Source
ZJCPC2004
Recommend
JGShining
代码:
#include<iostream>#include<map>#include<cstdio>using namespace std;int main(){int N;string str,now;map<string ,int >color;while(scanf("%d",&N),N){color.clear();for(int i=0;i<N;i++){cin>>str;color[str]++;}int max=0;map<string ,int>::iterator iter;for(iter=color.begin();iter!=color.end();iter++){if(iter->second>max){max=iter->second;now=iter->first;}}cout<<now<<endl;}return 0;}
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- Hdu 1004 - Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004--Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise STL
- http://www.360doc.com/content/12/0329/16/5600807_198996897.shtml
- ThinkPHP验证码
- malloc/free与new/delete的区别
- 内存段划分:代码段、数据段、堆、栈
- POJ-2243-Knight Moves
- hdu 1004 Let the Balloon Rise
- java开发中的Model1和Model2的对比
- erlang杂记五 --- 写了个小函数(1):一个字符串处理函数
- 数据结构顺序栈的各种操作
- SEAndroid在IPC中安全功能进行分析
- 新手如何快速掌握Eclipse进行高效开发
- 设M 是一个m×n 的矩阵,其中每行的元素从左到右单增有序,每列的元素从上到下单增有序。 给出一个分治算法计算出给定元素x 在M 中的位置或者表明x 不在M 中。分析算法的时间复杂性。
- ThinkPHP分页
- thinkphp登陆