Let the Balloon Rise
来源:互联网 发布:南风知我意txt免费下载 编辑:程序博客网 时间:2024/05/19 13:24
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 121311 Accepted Submission(s): 47673
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
很水。。。。。
import java.util.Scanner;import java.util.HashMap;public class Main {public static void main(String[] args) {// TODO 自动生成的方法存根Scanner in=new Scanner(System.in);int n;String ans;while((n=in.nextInt())>0){HashMap<String,Integer> s=new HashMap<String,Integer>();for(int i=0;i<n;i++){String temp=in.next();if(s.containsKey(temp)){s.put(temp,s.get(temp)+1);}else{s.put(temp, 1);}}ans="";int cnt=0;for(HashMap.Entry<String,Integer>e:s.entrySet()){if(e.getValue()>cnt){cnt=e.getValue();ans=e.getKey();}}System.out.println(ans);}}}
阅读全文
0 0
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the balloon rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- 对象克隆
- GIC-400寄存器 之CPU接口
- Android7.0中文文档(API)-- ShareActionProvider
- Solr单集代码调用案例
- UVa12100
- Let the Balloon Rise
- [mark]Chrome webdriver 下载
- [机器学习入门] 李弘毅机器学习笔记-17(Unsupervised Learning: Deep Auto-encoder;无监督学习:深度自动编码器)
- Error:Execution failed for task ':xxx:compileReleaseJavaWithJavac'.
- String、StringBuffer、StringBuilder
- Document对象,Element对象和Node对象简介
- oracle数据库锁表问题
- 反射
- Linux下报错DH GEX group out of range的理解