Let the Balloon Rise

时间:2021-11-17 05:52:50
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
#include<cstdio>
#include<cstring>
int main()
{
char s[][];
char temp[];
int a[];
int n,i,j;
while()
{
memset(a,,sizeof(a));
memset(temp,,sizeof(temp));
memset(s,,sizeof(s));
scanf("%d",&n);
if(!n) break;
for(i=; i<n; i++)
scanf("%s",s[i]);
for(i=; i<n-; i++)
{
if(a[i]<) continue;/*不这样做就会超时*/
for(j=i+; j<n; j++)
{
if(a[j]<) continue;
if(strcmp(s[i],s[j])==)
{
a[i]++;
a[j]=-;
strcpy(s[j],temp);
} }
}
int max=,maxi=;
for(i=; i<n; i++)
if(a[i]>max)
{
max=a[i];
maxi=i;
}
printf("%s\n",s[maxi]); }
}

Let the Balloon Rise的更多相关文章

  1. hdu 1004 Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  2. Let the Balloon Rise 分类: HDU 2015-06-19 19&colon;11 7人阅读 评论&lpar;0&rpar; 收藏

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  3. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  4. HDU1004 Let the Balloon Rise(map的简单用法)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  5. HD1004Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  6. Let the Balloon Rise&lpar;map&rpar;

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. akoj-1073- Let the Balloon Rise

    Let the Balloon Rise Time Limit:1000MS  Memory Limit:65536K Total Submit:92 Accepted:58 Description ...

  8. HDU 1004 Let the Balloon Rise【STL&lt&semi;map&gt&semi;】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  9. Let the Balloon Rise(水)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  10. ACM Let the Balloon Rise

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...

随机推荐

  1. JVM内存垃圾回收方法

    1.概述 1.1.为什么要回收? 如果不进行垃圾回收,内存迟早都会被消耗空,因为我们在不断地分配内存空间而不进行回收.除非内存无限大,我们可以任性地分配而不回收,但是事实并非如此.所以,垃圾回收是必须 ...

  2. ORACLE清除某一字段重复的数据(选取重复数据中另一个字段时期最大值)

    需求:资产维修表中同一资产可能维修完继续申请维修,这时候维修状态需要根据最近的维修时间去判断维修状态,所以同一资产ID下会出现重复的数据(维修审批通过,维修审批未通过),或者可能不出现(未申请维修), ...

  3. Asp&period;Net复习篇之Asp&period;Net生命周期与Asp&period;Net页的生命周期

    Asp.Net生命周期与Asp.Net页的生命周期是一个比较重要的话题,有时可能似乎知道一些,但又说不出个所以然,而且时常把这两个概念混淆.现在也是该好好理清思路,把这两个概念搞懂. Asp.Net生 ...

  4. 【水题递归】【HDU2044】我大沙茶了

    有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示.   Input 输入数据的第一行是一个整数N,表示测试实例的个数, ...

  5. windows 7 命令修改IP地址

    netsh interface ip set address "本地连接"  static 172.17.15.97 255.255.255.0 172.17.12.1

  6. POJ 1191棋盘分割问题

    棋盘分割问题 题目大意,将一个棋盘分割成k-1个矩形,每个矩形都对应一个权值,让所有的权值最小求分法 很像区间DP,但是也不能说就是 我们只要想好了一个怎么变成两个,剩下的就好了,但是怎么变,就是变化 ...

  7. CentOS7安装openjdk、tomcat和mysql流程介绍

    首先是前戏,推荐一个远程工具Xshell和Xftp搭配使用,以下是Xshell的官网 http://www.netsarang.com/products/xsh_overview.html 1.ope ...

  8. String&period;valueOf&lpar;object&rpar;&period;trim&lpar;&rpar;&rpar;

    获得对象的字段的值,然后转成string类型,并且去掉前后空白~~ToString()是转化为字符串的方法 Trim()是去两边空格的方法把StringBuffer转换成String类型时 没有用.t ...

  9. Zabbix server&lpar;离线版&rpar;安装手册

    由于zabbix server需要依赖MySQL及PHP的相关依赖,因此需要先安装好MySQL及PHP的相关依赖后方可安装zabbixserver. 安装MySQL 目录mysql下的rpm 1.新建 ...

  10. thinkphp图片上传&plus;validate表单验证&plus;图片木马检测&plus;缩略图生成

    目录 1.案例 1.1图片上传  1.2进行图片木马检测   1.3缩略图生成   1.4控制器中调用缩略图生成方法 1.案例 前言:在thinkphp框架的Thinkphp/Library/Thin ...