HDU 1800 Flying to the Mars 字典树,STL中的map ,哈希树
http://acm.hdu.edu.cn/showproblem.php?pid=1800
字典树
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
struct node
{
int sum;
node *next[];
node()
{
sum=;
memset(next, NULL, sizeof(next));
};
};
int ans;
char *Delleading0(char *s)
{
while(*s=='0')
s++;
while(*s==)
s--;
return s;
}
void Buildtiretree(node *head, char *s)
{
node *p=head;
for(int i=; s[i]; i++)
{
int k=s[i]-'0';
if(p->next[k]==NULL)
p->next[k]=new node();
p=p->next[k];
}
p->sum++;
if(p->sum>ans)
ans=p->sum;
}
int main()
{
char *s, str[];
int n;
while(scanf("%d", &n)!=EOF)
{
ans=;
node *head=new node();
//getchar();
while(n--)
{
//gets(str);
scanf("%s", str);
s=Delleading0(str);
Buildtiretree(head, s);
}
printf("%d\n", ans);
}
return;
}
HDU 1800 Flying to the Mars 字典树,STL中的map ,哈希树的更多相关文章
- hdu 1800 Flying to the Mars
Flying to the Mars 题意:找出题给的最少的递增序列(严格递增)的个数,其中序列中每个数字不多于30位:序列长度不长于3000: input: 4 (n) 10 20 30 04 ou ...
- HDU 1800——Flying to the Mars——————【字符串哈希】
Flying to the Mars Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU 1800 Flying to the Mars Trie或者hash
http://acm.hdu.edu.cn/showproblem.php?pid=1800 题目大意: 又是废话连篇 给你一些由数字组成的字符串,判断去掉前导0后那个字符串出现频率最高. 一开始敲h ...
- --hdu 1800 Flying to the Mars(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Ac code: #include<stdio.h> #include<std ...
- HDU - 1800 Flying to the Mars 【贪心】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1800 题意 给出N个人的 level 然后 高的level 的 人 是可以携带 比他低level 的人 ...
- hdu 1800 Flying to the Mars(简单模拟,string,字符串)
题目 又来了string的基本用法 //less than 30 digits //等级长度甚至是超过了int64,所以要用字符串来模拟,然后注意去掉前导零 //最多重复的个数就是答案 //关于str ...
- 杭电 1800 Flying to the Mars(贪心)
http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Oth ...
- HDOJ.1800 Flying to the Mars(贪心+map)
Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...
- HDOJ 1800 Flying to the Mars 盲目搜索......................so easy...........
check the original problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1800 the AC code: #include ...
随机推荐
- logstash5安装并实现mariadb数据写入到elasticsearch
java环境这里默认安装了 ,一般源码安装,这里就不说了 一.安装logstash 安装logstash可以用yum安装,也可以用源码安装: yum安装: 1.导入GPG: rpm --import ...
- Android Developer:合并清单文件
使用Android Studio而且基于Gradle构建.每一个App能在多个位置包括清单文件,比如在src/main文件夹下productFlavor.库.Android ARchive(AAR) ...
- Redis, Memcache, Mysql差别
在使用Redis过程中,我们发现了不少Redis不同于Memcached.也不同于MySQL的特征. (本文主要讨论Redis未启用VM支持情况) 1. Schema MySQL: 需事先设计 Mem ...
- 非常easy学习的JQuery库 : (二) 选择器
作用 选择器同意您对元素组或单个元素进行操作. 在前面的章节中,我们介绍了一些有关怎样选取 HTML 元素的实例. 关键点是学习 jQuery 选择器是怎样准确地选取您希望应用效果的元素. jQuer ...
- JavaFX打包到Android上
让JavaFX执行到移动平台一直是社区努力完毕的事. 当然,眼下已经能够让JavaFX执行到Android和IOS平台了,以下我们来看看怎样打包自己的JavaFX项目到Android平台. 首先下 ...
- ws 无法热替换的问题
这个坑自己踩过并且第二次就记录一下,因为一直习惯用ws, 使用热部署的时候发现无法自动同步热更新,找了很多方法,具体解决方式如下: webstorm默认保存在临时文件夹,根据下面路径将默认勾选项去除即 ...
- MapReduce中的排序(附代码)
在直接学习hadoop的排序之前还要了解一些基本知识. Hadoop的序列化和比较接口 Hadoop的序列化格式:Writable Writable是Hadoop自己的序列化格式,还要一个子接口是Wr ...
- 编写一个基于HBase的MR程序,结果遇到一个错:ERROR security.UserGroupInformation - PriviledgedActionException as ,求帮助
环境说明:Ubuntu12.04,使用CDH4.5,伪分布式环境 Hadoop配置如下: core-site.xml: <configuration><property> ...
- 【cogs182】【USACO Jan07】均衡队形【st表】
题目描写叙述 农夫约翰的 N (1 ≤ N ≤ 50,000) 头奶牛,每天挤奶时总会按相同的顺序站好. 一日.农夫约翰决定为奶牛们举行一个"终极飞盘"比赛.为简化问题.他将从奶牛 ...
- 搭建apphouse(docker镜像私服)
1.下载apphouse,地址为http://www.youruncloud.com/soft.html2.上传AppHouse_v1.0.2.tar到服务器并解压3../apphouse_insta ...