开始写技术博客了。
发发自己写的ACM的练习题。
杭电ACM1004 Let the Balloon Rise
http://acm.hdu.edu.cn/showproblem.php?pid=1004Problem 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
5
green
red
blue
red
red
3
pink
orange
pink 0
Sample Output
red
pink
1 //author:pz 2 3 import java.util.ArrayList; 4 import java.util.Scanner; 5 6 public class Main{ 7 8 public static void main(String args[]){ 9 Scanner scan = new Scanner(System.in); 10 while(scan.hasNextInt()){ 11 int n = scan.nextInt(); 12 if(n == 0) 13 break; 14 ArrayList<String> color = new ArrayList<String>(); 15 ArrayList<Integer> count = new ArrayList<Integer>(); 16 String c = scan.next(); 17 color.add(c); 18 count.add(1); 19 String modeColor=c; 20 Integer modeCount=1; 21 while(--n > 0){ 22 String s = scan.next(); 23 if(color.contains(s)){ 24 count.set(color.indexOf(s),count.get(color.indexOf(s))+1); 25 if(count.get(color.indexOf(s)) > modeCount){ 26 modeColor = s; 27 modeCount = count.get(color.indexOf(s)); 28 } 29 } 30 else{ 31 color.add(s); 32 count.add(1); 33 } 34 } 35 System.out.println(modeColor); 36 } 37 } 38 }
相关推荐
杭州电子科技大学acm第1004题 let the balloon rise
杭电ACM分类杭电ACM分类杭电ACM分类杭电ACM分类
#include #include int main(){ int n,a[1001],i,j,k,m,max; char str[1001][16],str1[1001][16]; while(scanf("%d",&n)!=EOF,n) { getchar();
北大杭电acm题解(详细)北大杭电acm题解(详细)北大杭电acm题解(详细)北大杭电acm题解(详细)北大杭电acm题解(详细)北大杭电acm题解(详细)
« ACM模板收集Let the Balloon Rise » Catalan数 Catalan numbers 的公式: Cn=C(2n,n)/(n+1);1 Cn+1=C(2n+2,n+1)/(n+2);2 由1和2推出 Cn/C(n+1)=(n+2)/(4n+2); 而且,对于一个具有n个节点的数的形态的...
杭电ACM2000-2011题已提交的代码!保证正确!
杭电acm 1000-2099 杭电acm 1000-2099 杭电acm 1000-2099 杭电acm 1000-2099
杭电acm培训课件,帮助新手系统学习acm竞赛规则和技巧
杭电ACM试题种类的分类。杭电ACM试题种类的分类。杭电ACM试题种类的分类。杭电ACM试题种类的分类。
杭电acm答案,都能够很容易理解,有需要的可以下载看看!!!杭电acm答案,都能够很容易理解,有需要的可以下载看看杭电acm答案,都能够很容易理解,有需要的可以下载看看杭电acm答案,都能够很容易理解,有需要的可以...
浙江杭电ACM教学资料,入门专用,格式PPt
这是杭电ACM第二部分资料,主要包括:回溯、数据结构、杭电ACM题集、几何2D等内容。
杭电acm部分答案主要以java为主,部分为c和c++;
杭电ACM模板,热爱的人可以看看,一点会有很多的收获的
杭电acm入门的相关文档 初识ACM·二分匹配及其应用· 搜索入门 等
杭电acm中两题简单的代码,都用的是简单的语句 对于初学者 很容易理解
杭电ACM基础题
杭电ACM -ppt 杭电ACM -ppt 杭电ACM -ppt 杭电ACM -ppt 杭电ACM -ppt 杭电ACM -ppt
杭电acm课件,数论,动态规划,博弈,并查集,探索,贪心,涵盖了入门必需的基本元素,强力推荐
这是杭电acm2000到2030的答案,分享下