HDOJ--1004
来源:互联网 发布:文华日内期货模型源码 编辑:程序博客网 时间:2024/06/11 04:26
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 95873 Accepted Submission(s): 36568
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
这题就是让你找到哪种气球的数量最多,并输出数量最多的气球的颜色。
还是一行一行的搜索并记录吧,你可以一边输入一边搜索,如果相同就在对应的位置上计数器加上1即可,然后就是简单的比大小输出相应位置的气球了。
以下是AC代码:
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;int main(){ int n,i,j,temp; while(scanf("%d",&n)==1 && n!=0) { getchar(); int max=0; int b[1010]; char a[1010][20]; memset(b,1,sizeof(b)); for(i=1;i<=n;i++) { gets(a[i]); for(j=1;j<i;j++) { if(!strcmp(a[j],a[i])) { b[j]++; break; } } } for(i=1;i<=n;i++) { if(b[i]!=1 && b[i]>max) { max=b[i]; temp=i; } } printf("%s\n",a[temp]); } return 0; }
0 0
- HDOJ 1004
- [HDOJ]1004
- HDOJ--1004
- hdoj 1004
- HDOJ 1004 Water~
- HDOJ 1004 字符串排序
- HDOJ 1004:Fibonacci Again
- HDOJ 1004 C语言版
- HDOJ 1004 Java 答案
- HDOJ
- hdoj
- hdoj
- HDOJ
- STL——HDOJ 1004
- 算法入门数学题hdoj 1004
- HDOJ 1004 Let The Ball Rise
- HDOJ热身赛1004--复习下排列组合公式
- HDOJ 1004 Let the Balloon Rise (map)
- SVN的Trunk、Branch和Tag(二)
- UML类图几种关系的总结
- SVN用户管理
- hadoop入门介绍
- html部分示例
- HDOJ--1004
- shell排序
- TortoiseSVN客户端重新设置用户名和密码
- html登录示例,以及各元素使用
- 分享几个javaweb开发工具的国内下载地址(IntelliJ Idea 15破解码地址/eclipse-j2ee官网版/eclipse-j2ee完全版/jstl.jar standard.jar)
- 链表之单链表的反转总结
- java 路径的困扰
- java基础之反射
- Ubuntu-安装-theano+caffe-超详细教程