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 ...
随机推荐
- Android的View 事件传递
欢迎转载,请附出处: http://blog.csdn.net/as02446418/article/details/47422891 1.基础知识 (1) 全部 Touch 事件都被封装成了 Mot ...
- ORACLE 表空间使用率查询
SELECT A.TABLESPACE_NAME, A.BYTES / (1024 * 1024 * 1024 ) TOTAL, B.BYTES / (1024 * 1024 * 1024 ) USE ...
- centos 6.9使用Rsync+Inotify-tools实现数据实时同步
centos 6.9使用Rsync+Inotify-tools实现数据实时同步 说明: 操作系统:CentOS 6.9 源服务器:192.168.1.222 备份服务器:192.168.1.1.233 ...
- html自定义标签属性
<a href="#" _asd="xxxx" onclick="test(event)">test</a> < ...
- android EditText控制最大输入行数
网络摘抄,仅作记录学习 EditText在android开发中是一个经常用到的基础控件,功能也很强大,限制输入字符类型,字数什么的.但是最近在工作中遇到了需要控制editText最大可输入行数的要求. ...
- staitic_cast原理与使用
本文以下述结构为例: 总结如下: 1) static_cast用于有直接或间接关系的指针或引用之间 转换.没有继承关系的指针不能用此转换,即使二者位于同一类体系中.比如,Left,Right之间不能用 ...
- 【JavaEE】Springmvc搭建方法及example
现在介绍SSH的文章很多,但是适合自己需求的却经常找不到,这些东西呢,会了之后总会感觉别人的程序哪里哪里别扭,会之前呢就感觉很混乱,而且SSH的官方文档,至少在我看来是“会者勉强能看.不会者一片迷茫” ...
- drupal7 使用(hook_preprocess_HOOK)向各个主题模版里面传递变量
函数地址:hook_preprocess_HOOK 1 首先解释下hook_preprocess_HOOK这个钩子的含义: hook _ preprocess _ H ...
- LR报错 No buffer space available Try changing the registry value 端口号不够用了
报错:Action.c(6): Error -27796: Failed to connect to server "10.16.137.8:10035": [10055] No ...
- Jmeter 05 JMeter元件详解
1. JMeter 逻辑控制器 Switch条件控制器.While条件控制器.交替控制器.仅一次控制器.随机控制器.随机顺序控制器.条件控制器(如果(if)).循环控制器.录制控制器.ForEach控 ...