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
 
Source
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; struct node
{
node* next[];
bool end;
int num;
node()
{
for(int i = ;i<;i++)
next[i] = NULL;
end = ;
num = ;
}
};
node* root;
char s[],ma[];
int mx;
int insert()
{
int l =strlen(s);
node* k = root;
int i,j;
for(i = ;i<l-;i++)
{
int id = s[i]-'a';
if(k->next[id] == NULL)
{
node* t = new node();
k->next[id] = t;
k = k->next[id];
}
else
{
k = k->next[id];
}
}
int id = s[i]-'a';
if(k->next[id] == NULL)
{
node* t = new node();
t->end = ,t->num = ;
k->next[id] = t;
k = k->next[id];
}
else
{
k = k->next[id];
k->num++;
}
return k->num;
} int main()
{
int n,i,j,k;
while(cin>>n,n)
{
root = new node();
mx = ;
for(i = ;i<n;i++)
{
cin>>s;
int t = insert();
if(mx<t)
{
mx = t;
int l = strlen(s);
for(j = ;j<=l;j++)
ma[j] = s[j];
}
}
cout<<ma<<endl;
}
return ; }

hdu1004Let the Balloon Rise的更多相关文章

  1. STL: HDU1004Let the Balloon Rise

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

  2. hdu 1004 Let the Balloon Rise

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

  3. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

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

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

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

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

  6. HD1004Let the Balloon Rise

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

  7. Let the Balloon Rise(map)

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

  8. akoj-1073- Let the Balloon Rise

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

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

随机推荐

  1. linq读书笔记3-操作符之select与selectmany

    linq对数据的查询方式的表达形式主要有两种: var demo =from p in pList where p.id=*** select p; var demo =pList.where(p=& ...

  2. win7系统64位安装oracle10g

    win7系统64位安装oracle10g 下载地址: http://download.oracle.com/otn/nt/oracle10g/10204/10204_vista_w2k8_x64_pr ...

  3. C#中的多线程使用 -- Thread 类详解(转)

    现在C#已经建议摈弃使用 Suspend, Resume 暂停/恢复线程, 也尽量少用 Abort方法中断一个线程. 建议使用线程的同步手段有: Mutex.ManualResetEvent.Auto ...

  4. vs2012配置opencv及简单测试

    为visual studio2012搭建openCV平台,实现打开图片. 实现步骤: 1.1.配置环境变量 基于win7操作系统的环境配置步骤: 1.1.1 计算机—>属性—>更改设置—& ...

  5. 开启MongoDB 脚本和设置window自启

    wwchen: D: cd D:\Program Files\MongoDB\Server\3.2\bin mongod --dbpath=D:\mongodb\db----------------- ...

  6. vi所有特殊字符

    vi5个特殊字符包含 /.^.$.*.. 在vi中用/查找时,()不做为特殊字符处理 比如:查找字符串(cyg_uint8 *)b 应该这样写 /(cyg_uint8 \*)b 只有 * 需要转义 \ ...

  7. Naive Bayes(朴素贝叶斯算法)[分类算法]

    Naïve Bayes(朴素贝叶斯)分类算法的实现 (1) 简介: (2)   算法描述: (3) <?php /* *Naive Bayes朴素贝叶斯算法(分类算法的实现) */ /* *把. ...

  8. Print! Print! Print!

    print语句可以实现打印--只是对程序员友好的标准输出流的接口而已. 从技术角度来讲,这是把一个或多个对象转换为其文本表达形式,然后发送给标准输出或另一个类似文件的流. 更详细地说,在Python中 ...

  9. ORA-01653:表无法通过64(在表空间USERS中)扩展

    问题描述:oracle插入数据时显示ORA-01653 表无法通过64(在表空间USERS中)扩展 原因:  oracle  表空间满了,需要扩展 截图: 解决方法: 1.首先查下表空间 select ...

  10. 定制化Azure站点Java运行环境(1)

    Azure website提供了为现代化的web应用程序快速部署的PAAS平台,可以让用户几分钟之内快速的将自己的应用部署到云端,并且提供了自动扩展(auto-scaling),SSL,多种语言(Ja ...