HDU1004 Check Balloon

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.