传送门:

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): 143275    Accepted Submission(s): 56670

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
 
 
题目意思:
找颜色单词出现得最多的那个单词
分析:
map的用法
很方便呀
原来都没有怎么用过
第一次用
开心
好用
code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n,n)
{
map<string,int> mm;
map <string,int>::iterator it;
string ch;
for(int i=;i<n;i++)
{
cin>>ch;
mm[ch]++;
}
int sum=;
string str;
for(it=mm.begin();it!=mm.end();it++)
{
if(it->second>sum)
{
sum=it->second;
str=it->first;
}
}
cout<<str<<endl;
}
return ;
}

HDU 1004 Let the Balloon Rise(map的使用)的更多相关文章

  1. 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 ...

  2. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  7. hdu 1004 Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  8. HDU 1004 - Let the Balloon Rise(map 用法样例)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  9. HDU 1004 Let the Balloon Rise(STL初体验之map)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

随机推荐

  1. MySql的InnoDB存储引擎--索引

    索引分类: 1.聚集索引:索引顺序与物理顺序一致. MySql 的 InnoDB 中,主键索引就是聚集索引.好处是,进行搜索的时候,因为索引和物理顺序一致,所以找数据的时候更快. 2.非聚集索引:索引 ...

  2. 解决:IDEA 中 new Java Class 怎么没了?

    前言:写代码时遇到的问题,所以记录下来.我的包名为“interface”,只有这个包及包下的文件不能建java文件. 问题 解决方式(对于普通包名) 点击应用,ok就可以了. 解决方式(对于包名为“i ...

  3. Dinic算法----最大流常用算法之一

    ——没有什么是一个BFS或一个DFS解决不了的:如果有,那就两个一起. 最大流的$EK$算法虽然简单,但时间复杂度是$O(nm^2)$,在竞赛中不太常用. 竞赛中常用的$Dinic$算法和$SAP$, ...

  4. 新版qq canvas 动态背景

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. css专业术语笔记

    1. 属性 如height.color等,称作css的属性. 2. 值 在css中,如:10px, 50%, #ccc等这些都称作css的值.比较常见的类型值有:整数值,数值,百分比值,长度值,颜色值 ...

  6. 主要看思路:区域数据去重 + JavaScript一次性展示几万条数据实例代码

    近期做1功能,Gis地图 基于百度地图api , 会遇到的问题的, 如后台接口给的数据很多,大几千上万的,如果拿了数据直接渲染dom ,这滋味爽爽的. 再遇上 客户端浏览器悲催的,这卡顿就来了... ...

  7. 解决servlet在web.xml中的路径跳转问题

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...

  8. Android LinkedList和ArrayList的区别

    LinkedeList和ArrayList都实现了List接口,但是它们的工作原理却不一样.它们之间最主要的区别在于ArrayList是可改变大小的数组,而LinkedList是双向链接串列(doub ...

  9. 通过Application存取公共数据比如登录信息等..

    Android系统在运行每一个程序应用的时候,都会创建一个Application对象,用于存储与整个应用相关的公共变量.一个Android应用只会生成一个Application对象,在不同的Activ ...

  10. 关于UNITY3D的各种各样。

    作为一个老C++程序员,在接触了UNITY3D之后,除了玩C#还得玩JAVA和OBJECTIVE-C. 1年多的经验证明,UNITY3D游戏项目,如果打算做多平台,项目组里必须得有一个会多语言的万金油 ...