zoukankan      html  css  js  c++  java
  • HDU1004Let the Balloon Rise

    Let the Balloon Rise

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 90663    Accepted Submission(s): 34466


    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
     

     

    Author
    WU, Jiazhi
     

     

    Source
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    using namespace std;
    char a[1005][20];
    int num[1005];
    int ii;
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            if(n==0)
            break;
            int maxs=-1;
            for(int i=0;i<n;i++)
            {
                scanf("%s",a[i]);
            }
            for(int i=0;i<n-1;i++)
            {
                int t=0;
                for(int j=i+1;j<n;j++)
                {
                    if(!strcmp(a[i],a[j]))
                    {
                        t++;
                    }
                }
                if(t>maxs)
                {
                    maxs=t;
                    ii=i;
                    //strcpy(b,a[i]);   //不能用,,
                }
            }
            printf("%s
    ",a[ii]);
        }
    }

     

    Recommend
    JGShining   |   We have carefully selected several similar problems for you:  1002 1008 1005 1019 1021 
  • 相关阅读:
    CentOS 7拨号上网(ADSL & PPPoE)
    linux使用nmcli重新生成网卡配置文件
    Linux 内存缓存占用过大,Centos7设置定时清除buff/cache的脚本
    部署redis6.0 常见问题
    ssh 升级导致的hadoop 主备切换失败
    配置zookeeper的 ACL权限
    sqoop 创建跟mysql相同表结构的hive表报错
    vim中显示不可见字符
    supervisor 使用
    使用hive streaming 统计Wordcount
  • 原文地址:https://www.cnblogs.com/dshn/p/4754466.html
Copyright © 2011-2022 走看看