Font Size: ← →

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
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define Max 1005
using namespace std;char a[Max][20];
int  b[Max];int main(void)
{//freopen("in.txt","r",stdin);int n;while(scanf("%d",&n)!=EOF&&n){getchar();memset(b,0,sizeof(b));for(int i=1;i<=n;i++)gets(a[i]);for(int i=1;i<=n;i++){for(int j=i+1;j<=n;j++){if(strcmp(a[i],a[j])==0){b[i]++;}}}int max=0,count=1;for(int i=1;i<=n;i++){if(b[i]>max){max=b[i];count=i;}}printf("%s\n",a[count]);}//fclose(stdin);return 0;
}

转载于:https://www.cnblogs.com/phaLQ/p/10030048.html

HDOJ_1004_Let the Balloon Rise相关推荐

  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. HDOJ 1004 Let the Balloon Rise

    2019独角兽企业重金招聘Python工程师标准>>> 開源中國寫的第一篇日誌 加油 水呀水 ,不過水壓不小,暈死,一晚上就死在了這裡, 回想一下這題真的真的不難 一開始是思路問題, ...

  5. HDU 1004 Let the Balloon Rise (map)

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

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

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

  7. hdu1004——Let the Balloon Rise

    原题: Problem Description Contest time again! How excited it is to see balloons floating around. But t ...

  8. HDU - Let the Balloon Rise(STL)

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

  9. HDU 1004 Let the Balloon Rise

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

最新文章

  1. 【HAOI2010】订货
  2. Get SQL String From Query Object In Entity Framework
  3. go waitgroup.done()异常处理_Go 异常处理
  4. 在洛谷开了一个邀请赛
  5. Python3实现翻转二叉树问题
  6. cf 1059e 思维 贪心 树
  7. iBiology |专业的生信科普网站
  8. Unity中使用多构造函数(转)
  9. Leetcode 129. 根到叶子结点数字之和
  10. EXCEL 选中单元格并拖动等操作。
  11. 2017-2018-1 20155317《信息安全系统设计基础》 实验五 通讯协议设计
  12. 我奋斗了18年,不是为了和你一起喝咖啡
  13. XFire野猪书-XFire开发指南第二版
  14. Android Layout inflate过程分析(1)
  15. 运用深度学习进行文本生成
  16. 第十章 搭建nRF52开发环境(SES)
  17. 交换机putty怎么调试_【技术】如何登陆交换机进行命令配置?常用的交换机组网模拟器有哪些?...
  18. C语言之——自定义数据类型
  19. 免费资源丨如何快速发表论文?八种实验套路及论文技巧告诉你
  20. speedoffice文档中如何绘制流程图

热门文章

  1. 从入门到精通!零基础上手车辆目标跟踪与计数
  2. CVPR 2021 | 大幅涨点!新型动态激活函数和轻量级网络TFNet
  3. 综述 | 卷积神经网络:从基础技术到研究前景
  4. 接收率高达29%的ICLR 2021有哪些论文入榜呢?
  5. 常见特征检测算法介绍
  6. 零基础入门深度学习 | 第一章:感知器
  7. 机器学习(二)逻辑回归
  8. mysql my includedir_MySQL:读取my.cnf的顺序问题
  9. tortoise从服务器获取项目_项目中一次网络问题处理的复盘
  10. android stepview 京东,Android-Android-OpenAPI SDK-帮助文档-京东云