Let the Balloon Rise
来源:互联网 发布:国航网上值机软件 编辑:程序博客网 时间:2024/06/04 19:00
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.
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.
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
Author
WU, Jiazhi
Source
ZJCPC2004
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cstdlib>#include<cmath>using namespace std;int main(){ int i,j,k,n,num[1000],max,t; char color[1000][16]; while(scanf("%d",&n)!=EOF) { if(n) { num[0]=0; scanf("%s",color[0]); for(i=1;i<n;i++) { num[i]=0; scanf("%s",color[i]); for(j=0;j<=i-1;j++) { if(strcmp(color[i],color[j])==0) num[i]+=1; } } max=0; t=0; for(i=1;i<n;i++) { if(max<num[i]) { max=num[i]; t=i; } } printf("%s\n",color[t]); } } return 0;}
阅读全文
0 0
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the balloon rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- 学习kubernetes
- js获取当前时间 显示的格式类型2017-06-03 16:13:12
- erase方法+erase(lob,amount,offset)+使用erase方法
- Caffe 深度学习框架上手教程
- extern关键字的使用
- Let the Balloon Rise
- ZOJ 2588 Burning Bridges
- 倍增LCA模板
- ##报错:DrawerLayout must be measured with MeasureSpec.EXACTLY.
- ssm整合:
- LiteIDE中漂亮的几款QSS
- mybatis快速入门
- 中间缓存变量机制 i++
- javascript开发:javascript基础知识点