Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 104108    Accepted Submission(s): 40046

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
 
题目大意:找出出现最多次数的字符串

思路:简单map

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
    int n, max;
    ];
    map<string,int> one;
    map<string, int>::iterator itea;
    string str;
    while(cin>>n&&n)
    {
        while(n--)
        {
            cin>>str;
            one[str]++;
        }
        ,itea=one.begin();itea!=one.end();++itea)
        {
            if(itea->second>max)
                {
                max=itea->second;
                str=itea->first;
                }
        }
        cout<<str<<endl;
        one.clear();
    }
 } 

HDU 1004 Let the Balloon Rise map的更多相关文章

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

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

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

  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. Struts2中<jsp:forward page="xxx.action"></jsp:forward>失效

    问题:在Struts2中<jsp:forward page="xxx.action"></jsp:forward>失效了,不但调转不过去还报404错误.不知 ...

  2. struts2中Double类型的转换

    今天做项目,ssh + Extjs,页面js中定义了几个NumberField,对应的value都是double类型的,其中有个NumberField的name为 name,结果执行的时候报错了,说找 ...

  3. sql 表连接 join

    inner join  和  join  的 区别 inner join 是内连接 ,查询出两边 都有的数据 join  是交叉 连接, 假设集合A={a, b},集合B={0, 1, 2},则两个集 ...

  4. LoadRunner11下载以及详细破解说明【最新】

    Loadrunner11破解所需两个dll文件以及自动删除注册表工具,使用方法见附件readme.也可安装网上的办法,手动删除注册表项. 下载破解文件lm70.dll和mlr5lprg.dll lm7 ...

  5. java concurrency in practice读书笔记---ThreadLocal原理

    ThreadLocal这个类很强大,用处十分广泛,可以解决多线程之间共享变量问题,那么ThreadLocal的原理是什么样呢?源代码最能说明问题! public class ThreadLocal&l ...

  6. 161102、MyBatis中批量插入

    方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...

  7. 安装SQL Server 2005

    在安装SQL Server 2005时,经常会遇到一些错误,从而使系统无法正常安装.下面讲解在安装过程中经常出现的一些错误及其解决的方法.1.解决在安装SQL Server 2005时安装程序被挂起的 ...

  8. Spring+Mybatis整合报错Mapped Statements collection does not contain value原因之一

    报错如下: ### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements coll ...

  9. zjtd 2016面试

    1.写一个函数get_next() class A{ public :int next();   //取下一个值,并且指针后移 bool has_next(); private: //可以认为是一个q ...

  10. PHP给图片加文字(水印)

    准备工作: 代码: <?php header("Content-type: image/jpeg"); //浏览器输出,如不需要可去掉此行 $im = @imagecreat ...