题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

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

Problem solving report:

Description: 有多种颜色的气球,统计它们的个数,并找出数量最多的那种颜色。 
Problem solving: 利用C++里面的map直接统计每个颜色出现的次数,然后找最大的就行了。

Accepted Code:

#include <bits/stdc++.h>
using namespace std;
int main() {int n;char str[20];while (scanf("%d", &n), n) {map <string, int> spt;for (int i = 0; i < n; i++) {scanf("%s", str);spt[str]++;}string s; int max_ = 0;map <string, int>::iterator it;for (it = spt.begin(); it != spt.end(); it++) {if (it -> second > max_) {s = it -> first;max_ = it -> second;}}printf("%s\n", s.c_str());}return 0;
}

HDU - Let the Balloon Rise(STL)相关推荐

  1. HDU.1004 Let the Balloon Rise

    原题 HDU.1004 Let the Balloon Rise 分类 杂题 题意 找出一组序列中出现次数最多的字符串. 输入/输出 要求与格式 样例数的确定 最后一个样例输入字符串个数为0代表样例输 ...

  2. [HDU1004] Let the balloon rise - 让气球升起来

    [HDU1004] Let the balloon rise - 让气球升起来 Description Contest time again! How excited it is to see bal ...

  3. hdu-1004 Let the Balloon Rise

    题目来源:hdu-1004 Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...

  4. HDU 1004 Let the Balloon Rise (map)

    题目链接 Problem Description Contest time again! How excited it is to see balloons floating around. But ...

  5. HDU 1004 Let the Balloon Rise

    字典树(Trie) 题意是说找出最多的颜色.也就是找出出现次数最多的单词. 插入,然后遍历一遍把最多的输出就能够. #include<cstdio> #include<cstring ...

  6. 杭电HDU 1004 Let the Balloon Rise AC代码 简单题

    题目很简单,大致意思是有多组测试数据,每组测试数据里找出出现次数最多的字符串,输入0结束.这个题没什么坑点,而且题目说了是唯一解. 用了结构体,algorithm里的sort函数就解决了,贴 C++的 ...

  7. HDU 2607 Let the Balloon Rise II 水

    很早写过的一个题目,又碰到了还是写一下- -,看好多大神都有二分查找过的,然后我感觉题目既然说了只有一个是奇数,那么根据异或规则可以把所以数字异或之后剩下的就是这个数字,查找一遍就好了. #inclu ...

  8. hdu 4268 Alice and Bob(STL版)

    http://acm.hdu.edu.cn/showproblem.php?pid=4268 这是今天网络赛的水题,下午短路了,没想到怎么做.队友hq是用treap做的,不过赛后我才想懂怎么做,回到宿 ...

  9. 算法设计与分析之ZOJ2104- Let the Balloon Rise

    问题描述 输入   输入有多组测试例.   对每个测试例,第一个数字是N(0<N<1000),表示气球的数量.接下来N行,每行是一个气球的颜色,由小写字母构成的字符串表示,长度不超过15个 ...

最新文章

  1. 小鱼易连获腾讯数亿C轮投资,云视频布局产业互联网
  2. 25岁社招进阿里,从电商到有赞新零售,他仅1年就打开了马云一直想做的新领域!
  3. [YTU]_2640( 编程题:运算符重载---矩阵求和)
  4. zip()和zip(*)的区别与使用
  5. Python编程:Tkinter图形界面设计(1)
  6. Oracle日期格式化问题:to_date(sysdate,'yyyy-MM-dd')与 to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd')区别
  7. SpringBoot之基础
  8. 汇编Ring 3下实现 HOOK API
  9. ad18修改过孔和走线间距_PCB设计之“过孔”
  10. 开课吧:C++STL常用remove算法有哪些?
  11. linux下二进制包、源代码包、rpm包
  12. chrome 独立安装包下载
  13. 【细胞分割】基于中值滤波+分水岭法实现细胞计数matlab源码
  14. 【原创】JQWidgets-TreeGrid 2、初探源码
  15. 屏幕录像专家2014 v0318 免费版
  16. Sigil制作epub,正则表达式的使用
  17. RocksDB原理介绍
  18. 网络吞吐量对网络的影响
  19. 中国 GitHub 霸榜乱象! 国内程序员的脸都被丢尽了!
  20. 蓝桥杯—拉马车—思路透彻

热门文章

  1. linux下x86和arm架构区别
  2. ICASSP2021:端到端的图像编码方法
  3. Flink 案件分区 处理函数(KeyedProcessFunction)
  4. USACO2007 捕牛记 /// queue+桶 oj1503
  5. 第21次CCF计算机软件能力认证【期末预测之最佳阈值】【期末预测之安全指数】
  6. C#版 Socket编程(同步)
  7. java keyset ==_Java中keySet()返回值的排序问题
  8. 网站页面浏览次数代码mysql_php统计网站/html页面浏览访问次数程序
  9. CTF实战(隐写术):欢迎来到地狱
  10. 百度地图升级6:添加百度个性化地图及注意事项!