HDU 1004:Let the Balloon Rise
2016-01-30 09:18
429 查看
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 98230 Accepted Submission(s): 37599
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
Author
WU, Jiazhi
Source
ZJCPC2004
Recommend
JGShining | We have carefully selected several similar problems for you: 1003 1019 1013 1012 1020
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
int i,a,max[1005],ma=0,jj=0;
string s[1005];
while(cin>>a&&a)
{
ma=0,jj=0;
memset(max,0,sizeof(max));
for(i=0; i<a; i++)
{
cin>>s[i];
for(int k=0; k<i; k++)
if(s[k]==s[i])max[i]++;
}
for(i=0; i<a; i++)
if(ma<max[i])
ma=max[i],jj=i;
cout<<s[jj]<<endl;
}
return 0;
}
相关文章推荐
- OSG+QT5+vs2010编译
- 原子性操作atomic_t
- 面试笔试杂项积累-leetcode 31-35
- hdu 2045(递推)
- python 数据类型转换
- 将顺序表L1中的数据进行分类,奇数存放到存到顺序表L2中,偶数存到顺序表L3中
- 前端开发的正确姿势——各种文件的目录结构规划及引用
- ArduinoYun教程之配置Arduino Yun环境
- 使用Maven构建和部署J2EE应用程序的EAR文件
- JS输入银行卡号,4位自动加空格
- 顺序表的就地倒置
- python string与list互转
- thinkphp整合ueditor(百度编辑器)方法详解
- 使用HTML5构建iOS8原生APP
- Python 8.4 进程 vs 线程
- Linux acpi off学习
- BZOJ 4326 运输计划 transport 【NOIP 2015】【树链剖分】
- Solr5.2的配置
- Solr5.2的配置
- 日经春秋 20160130