Let the Balloon Rise
2015-08-04 11:19
302 查看
Let the Balloon Rise
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 19 Accepted Submission(s) : 6
result.
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
Let the Balloon Rise
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 19 Accepted Submission(s) : 6
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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 theresult.
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
#include<iostream> #include<string> #include<stdio.h> #include<map> using namespace std; int main() { map<string,int> m; //map<string,int>::iterator it; int Max; string s; int n; int i,j; while(scanf("%d",&n),n) { Max=-1; for(i=0;i<n;i++) { cin>>s; m[s]++; } for(map<string,int>::iterator it=m.begin();it!=m.end();it++) if((*it).second>Max) { s=(*it).first; Max=(*it).second;} cout<<s<<endl; m.clear(); } return 0; }
相关文章推荐
- Rsync安装手册
- final....
- HTML5中的本地存储sessionStorage、localStorage、Web SQL Database
- Ubuntu下Eclipse无法正常启动问题解决
- 制造企业生产类型
- postgreSql导出数据库数据
- cocos2d-x 学习笔记之生成Android Apk文件
- apache kafka中server.properties配置文件参数说明
- poj-1575-Easier Done Than Said?
- 菜鸟总结so分析,arm 汇编,IDA静态分析
- HDU 2501 Tiling_easy version
- HDU--1394 Minimum Inversion Number
- simple-spring-memcached简介
- xhEditor用法
- SQL Server 去掉列中的空格
- (leetcode)Summary Ranges
- IOS第七天(2:UiTableView 加上数据分离)
- 第17章 文本和字体_17.4 字体枚举
- 《ES6基础教程》之 Call 方法和 Apply 方法
- 【Unity】关于音乐音效管理以及dontDestroyOnLoad重复实例化问题