博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
STL: HDU1004Let the Balloon Rise
阅读量:7032 次
发布时间:2019-06-28

本文共 1698 字,大约阅读时间需要 5 分钟。

Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 124433    Accepted Submission(s): 49101
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
 
Source
#include
#include
#include
#include
using namespace std;int main(){
map
mp; string color,tmp; int n; while(scanf("%d",&n)==1 && n){
mp.clear(); for(int i=1;i<=n;i++){
cin >> color; mp[color]++; } map
::iterator it; int ans = -1; for(it=mp.begin();it!=mp.end();it++){ if((*it).second > ans ){ ans = (*it).second; color = (*it).first; } } printf("%s\n",color.c_str()); }}

转载于:https://www.cnblogs.com/Pretty9/p/7347701.html

你可能感兴趣的文章
goLang 文件操作之二
查看>>
7大维度看国外企业为啥选择gRPC打造高性能微服务?
查看>>
HTTP协议类
查看>>
建造者模式
查看>>
【redux篇】middleware 之 redux-thunk
查看>>
数据结构---图的相关总结
查看>>
Linux平台上部署Mongoose服务器的方法介绍
查看>>
Node中间层实践(二)——搭建项目框架
查看>>
erget源码分析(2):全局哈希基类和全局异步函数对象接口
查看>>
解码方法
查看>>
Electron入门介绍
查看>>
从egg.js重新认识node后端开发
查看>>
聊聊springboot session timeout参数设置
查看>>
微信小程序调研
查看>>
window下git多账户管理
查看>>
【327天】我爱刷题系列086(2017.12.29)
查看>>
React.js 小书 Lesson15 - 实战分析:评论功能(二)
查看>>
如何使用JSON和GSON
查看>>
weex脚手架
查看>>
js正则表达式学习
查看>>