Let the Balloon Rise

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

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
题解:题意很简单,就是求出现最多的字符串;
代码:
  #include<stdio.h>
#include<map>
#include<string>
#include<string.h>
using namespace std;
map<string,int>mp;
int main(){
int N;
char s[],ans[];
while(~scanf("%d",&N),N){
mp.clear();
int temp=;
for(int i=;i<=N;i++){
scanf("%s",s);
mp[s]++;
//printf("mp[%s]=%d\n",s,mp[s]);
if(mp[s]>temp){
temp=mp[s];
strcpy(ans,s);
}
}
printf("%s\n",ans);
}
return ;
}

Let the Balloon Rise(map)的更多相关文章

  1. 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 ...

  2. Let the Balloon Rise <map>的应用

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

  3. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  4. Let the Balloon Rise map一个数组

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

  5. hdoj-1004-Let the Balloon Rise(map排序)

    map按照value排序 #include <iostream> #include <algorithm> #include <cstring> #include ...

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

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

  7. HDU 1004 Let the Balloon Rise【STL<map>】

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

  8. hdu 1004 Let the Balloon Rise strcmp、map、trie树

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

  9. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

随机推荐

  1. 关于Nexus 7的Usb host开发问题

    按照API Guides和搜索到的各种方法,都没办法把Nexus 7上面的USB 设备列举出来.使用市场上的软件依然不行. 在找demo的时候找到一位大神chainfire,他似乎有所解释 看来得换一 ...

  2. [Backbone.js]如何用backbone写一个仿网页版微信的webapp?

    var Chat = Backbone.Model.extend({ idAttribute:'id', initialize:function(options){ var users = this. ...

  3. 《零基础学习Python》01

    前言 Python是一种跨平台的语言 安装Python(Mac OS X) 1.在www.python.org/downloads 中下载Python,然后像安装其他软件一样进行安装. 2.打开: 找 ...

  4. Oracle EBS-SQL (BOM-9):检查系统BOM总数.sql

    SELECT      ITM.SEGMENT1                         物料编码     ,ITM.DESCRIPTION                     物料描述  ...

  5. The solution for "Eclipse is running in a JRE, but a JDK is required"

    Open the eclipse folder and access the eclipse.ini file:   Before change it ,you will find it don’t ...

  6. TPen的7种Style和16种Mode

    //TPen 的主要属性有四: Color.Width.Style.Mode {Color: 颜色} {Width: 宽度; 默认是 1; 如果赋予 <= 0 的值, 会使用默认值} {Styl ...

  7. JavaScript实现定点圆周运动

    目是这样的:假设有一定点(400px,300px),通过JavaScript使一个直径20px的圆点以 r=180px 为半径围绕该点做匀速圆周运动. 这个问题的整体实现思想应该是这样的,看到“半径” ...

  8. git使用三把斧

    git status                                           -查看哪些更改 git add file1 file2                     ...

  9. <select>标签后循环加入选项<option>——jquery

    if (data.ReplaceDataFields != null) { $.each(data.ReplaceDataFields, function (i, item) {            ...

  10. C# 如何利用反射来加载程序集,并调用程序集中有关类的方法【转】

    假设在C盘根目录下有个Dog的Dll程序集文件,该程序集文件中包含类Dog 该类中有个狗叫几声的方法,如何通过反射来加载这个C:\Dog.dll,并且调用Dog类里面的Sound方法呢: public ...