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. paper 27 :图像/视觉显著性检测技术发展情况梳理(Saliency Detection、Visual Attention)

    1. 早期C. Koch与S. Ullman的研究工作. 他们提出了非常有影响力的生物启发模型. C. Koch and S. Ullman . Shifts in selective visual ...

  2. Bootstrap布局设计

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

  3. oracle索引使用时注意

    1.使用不等于操作符(<>, !=)下面这种情况,即使在列dept_id有一个索引,查询语句仍然执行一次全表扫描 select * from dept where staff_num &l ...

  4. Oracle的分页查询

    --1:无ORDER BY排序的写法.(效率最高)--(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!) SELECT * FROM (SELECT ...

  5. zw版【转发·台湾nvp系列例程】HALCON MirrorRegion (Delphi)

    zw版[转发·台湾nvp系列例程]HALCON MirrorRegion (Delphi) procedure TForm1.Button1Click(Sender: TObject);var img ...

  6. keep your work after network broken

    如下设置可以保证在网络中断后tso仍然可以继续active,并等到下一次reconnect sys1.tcpparms(tnprof7d) -- Dataset name and PDS name b ...

  7. STM32的PWM输出极性的问题

    又开始玩PWM, 先试了一下PWM的两个引脚输出相反极性, 但是分析仪上看到, 两个脚是一样一样的. 写是这么写的: ... TIM_OCInitStructure.TIM_OCMode=TIM_OC ...

  8. 内存泄露:*.hprof

    使用Memory Analyzer tool(MAT)分析内存泄漏 转账地址:http://www.blogjava.net/rosen/archive/2010/06/13/323522.html ...

  9. function adapter(函数适配器)和迭代器适配器

    所谓function adapter(函数适配器)是指能够将不同的函数对象(或是和某值或某寻常函数)结合起来的东西,它自身也是个函数对象. 迭代器适配器  运用STL中的迭代器适配器,可以使得算法能够 ...

  10. js闭包的产生

    当函数可以记住并访问所在的词法作用域, 即函数是在当前词法作用域之外执行, 这时就产生了闭包. function a () { function b () {   //函数b的词法作用域是在函数a内 ...