Let the Balloon Rise
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 102132 Accepted Submission (s): 39192
Problem Descriptioncontest Time again! How excited it was to see balloons floating around. But to tell you a secret, the judges ' favorite time was guessing the most popular problem. When the contest was over, they would count the balloons of each color and find the result.
This is the year that they decide to leave the lovely job to you.
Inputinput contains multiple test cases. Each test case is starts with a number n (0 < N <=) – 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 lower-case letters.
A test Case with N = 0 terminates the-input and this-test case are not-to-be processed.
Outputfor each case, print the color of balloon for the most popular problem to a single line. It is guaranteed this there is a unique solution for each test case.
Sample Input5greenredblueredred3pinkorangepink0
Sample Outputredpink
AUTHORWU, Jiazhi
SourceZJCPC2004
recommendjgshining | We have carefully selected several similar problems for you:1008 1019 1021 1013 1012
#include <string.h>#include<iostream>#include<algorithm>#include<stdlib.h>#include<stdio.h>using namespacestd;intMain () {inti,j,n,t; while(cin>>n&&N) {Charc[1005][ -]; inta[1005]; Memset (A,0,sizeof(a)); for(i=0; i<n;i++) {cin>>C[i]; for(j=0; j<i;j++) { if(strcmp (c[i],c[j]) = =0) A[i]++; } } intmax=0, t=0; for(i=0; i<n;i++) { if(a[i]>max) {Max=A[i]; T=i; }} cout<<c[t]<<Endl; } return 0;}
HDU1004 Check Balloon