1004 Let the Balloon Rise
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 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.
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.
5 green red blue red red 3 pink orange pink 0
#include<iostream>
#include<string>
using namespace std;
#define N 100000
int main()
{
int t;
cin>>t;
while(t)
{
string s[N];
int max=0,m=0;
for(int i=0;i<t;i++)
{
cin>>s[i];
}
getchar();
int a[N]={0};
for(int i=0;i<t;i++)
{
for(int j=i;j<t;j++)
{
if(s[i]==s[j])
a[i]+=1;
}
}
for(int i=0;i<t;i++)
{
if(a[i]>max)
{
m=i;
max=a[i];
}
}
cout<<s[m]<<endl;
cin>>t;
}
}
1004 Let the Balloon Rise的更多相关文章
- hdu 1004 Let the Balloon Rise(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise(map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise【STL<map>】
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU 1004 Let the Balloon Rise map
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise strcmp、map、trie树
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 杭电1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hduoj#1004 -Let the Balloon Rise [链表解法]
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Problem Description Contest time again! How exci ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- HDU 1004 - Let the Balloon Rise(map 用法样例)
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
随机推荐
- 深入浅出数据结构C语言版(1)——什么是数据结构及算法
在很多数据结构相关的书籍,尤其是中文书籍中,常常把数据结构与算法"混合"起来讲,导致很多人初学时对于"数据结构"这个词的意思把握不准,从而降低了学习兴趣和学习信 ...
- 交叉编译Python-2.7.13到ARM(aarch32)—— 支持sqlite3
作者:彭东林 邮箱:pengdonglin137@163.com QQ: 405728433 环境 主机: ubuntu14.04 64bit 开发板: qemu + vexpress-a9 (参考: ...
- Mobiscroll日期插件使用
相关资源 官方帮助文档:https://docs.mobiscroll.com/3-0-1 导入资源文件 <link href="${webRoot}/template/green/w ...
- iOS开发之单例模式
1.概述 单例模式是一种常用的软件设计模式,通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问,从而方便对实例个数的控制并节约系统资源. 如果希望系统中某个类的对象只能存在一个,单例模 ...
- oracle学习 笔记(2)
题记:在使用Oracle数据库的时候,发现Oracle是没有自动增长列来实现主键的,所以在此记录学习.(PS:如果哪里有错误或者不足的地方还请大家帮忙指出来) 二.序列(自动增长列) 为此问题博主也是 ...
- Unity无缝循环世界实现
一年前曾经碰到过已无限世界为题材的游戏开发比赛,虽然对比赛没有兴趣,但是对这个题材倒是有点想法.如何通过unity3d实现无缝的循环世界呢. 有一种想法是动态生成,一块场景一块场景进行动态加载.(做过 ...
- Python之路-Linux命令基础(1)
开启Linux操作系统,要求以root用户登录GNOME图形界面,语言支持选择为汉语 使用快捷键切换到虚拟终端2,使用普通用户身份登录,查看系统提示符,使用命令退出虚拟终端 ...
- 老李分享:loadrunner 的86401错误
老李分享:loadrunner 的86401错误 系统和软件配置: os:windows 2003loadruner版本:LoadRunner11loadrunner:协议:SMTP协议并发数:2 ...
- Framework7初始化
/** * Framework7初始化 * 需引用jQuery */ /*---------------------------函数---------------------------*/ /** ...
- (iOS)关于UITableView设置contentsize(原创)
由于UITableView是继承自UIScrollView的,所以他是可以设置contentsize的. 但是,我在试验的过程中,初始化UITableView实例后,直接设置它的contentsize ...