hdu——1004
发布日期:2022-02-02 02:58:03 浏览次数:14 分类:技术文章

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

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
5greenredblueredred3pinkorangepink0
 
Sample Output
redpink
分析:

#include 
#include
using namespace std;int main(){ int n; while(cin>>n&&n) { string str[1001]; for(int i=1; i<=n; i++) { cin>>str[i]; } int sum[1001]; for(int i=1; i<=n; i++) sum[i]=1; int max=1; for(int i=2; i<=n; i++) { if(str[i]==str[i-1]) { sum[i]+=sum[i-1]; } if(sum[i]>=sum[max]) max=i; } cout<
<

转载地址:https://blog.csdn.net/u010368749/article/details/12715899 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:hdu——Big Number
下一篇:Problem 2122 又见LKity

发表评论

最新留言

很好
[***.229.124.182]2024年04月10日 04时35分17秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

冒泡排序完整代码讲解 2019-04-26
深夜不睡的我爬取一下美女照片!!!哈哈!!来吧,刺激磁刺激!!! 2019-04-26
自带Microsofa store无法加载页面最简单有效解决办法 2019-04-26
九行代码带你爬取任何你想要爬取的图片保存到文件夹(完整代码,只要你的赞和关注) 2019-04-26
使用scikit-learn对给西瓜数据集进行分类任务,详述项目过程,对模型进行调参并给出一组最优参数 2019-04-26
C语言编写一个计算器(附全源代码) 2019-04-26
MySql操作(一):数据库的全部基础详细操作与命令 2019-04-26
MySql操作(二):表的全部基础详细操作与命令 2019-04-26
python输入字符串,统计字母和数字有多少 2019-04-26
python鸡兔同笼问题 2019-04-26
python求解一元二次方程 2019-04-26
打砖游戏,详解每一行代码,历经三个小时解析,初学可看 2019-04-26
进入chrome商店方法 2019-04-26
html:修改版火影忍者静态网页设计,实例三(附带完整源码) 2019-04-26
Java学习:MyEclipse下载以及安装步骤,详细贴图每一个步骤,包教包会 2019-04-26
解决win10安装虚拟网卡,却没有自带虚拟网卡问题,详细贴图讲解 2019-04-26
呕心沥血解析用python画一个表白树(详解每一行代码),初学者也能看懂,授人以鱼不如授人以渔 2019-04-26
C语言:定义一个计算两个整数的和的函数int sum(int a,int b),在主函数中输入两个整数x和y,调用sum(x,y)输出x+y的和。 2019-04-26
C语言: 定义一个函数int fun(int n),用来计算整数的阶乘,在主函数中输入一个变量x,调用fun(x)输出x及以下的阶乘值。 2019-04-26
C语言: 定义一个函数int isprime(int n),用来判别一个正整数n是否为素数,若为素数函数返回值为1,否则为0。在主函数中输入一个整数x,调用函数isprime(x)来判断这个整数x是 2019-04-26