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 ...
随机推荐
- 用unity3d实现简单的主server连接
用unity3d实现简单的主server连接 參考自鹰大的网络实例 -------------------------------------------------华丽的切割线----------- ...
- CoreAnimation的使用小结
參考:http://www.cnblogs.com/wendingding/p/3801157.htmlhttp://www.cnblogs.com/wendingding/p/3802830.htm ...
- [Erlang危机](5.1.1)内存
原创文章,转载请注明出处:server非业余研究http://blog.csdn.net/erlib 作者Sunface , and some of the hidden data I mention ...
- 自动清理DataGuard备机日志
>> from zhuhaiqing.info #!/usr/bin/bash #删除DataGuard备机归档日志备份 export ORACLE_HOME=/opt/oracle/pr ...
- java多线程之happens-before
1.背景问题 在讲happens-before之前,先引入一个例子: 假定我们有已经被初始化的变量: int counter = 0; 这个 counter 变量被两个线程所共有,也就是说线程A和线程 ...
- Spigot 算法之中的一个 计算调和级数的和
我是首先在[1] 注意到 Spigot-Algorithm的,这个算法公布的相当早.见[2]. [1] 给出几个令人惊异的程序.仅仅用非常少的代码就能够计算e,pi,log(2)等常数. 当中 ...
- 2017年Android百大框架排行榜(转)
一.榜单介绍 排行榜包括四大类: 单一框架:仅提供路由.网络层.UI层.通信层或其他单一功能的框架 混合开发框架:提供开发hybrid app.h5与webview结合能力.web app能力的框架 ...
- ftp put get 的使用方法
首先:ftp user@ip 登录到远程主机 成功后,输入ls,如下: ftp> ls 可以得到远程主机的本地目录. 一:get命令(从远程主机下载文件到本机): ftp> get (re ...
- Java多态案例分析
一.多态的定义 同一事物,在不同时刻体现出不同状态. 例如:水在不同状态可能是:气态.液态.固态. 二.多态前提和体现 1.有继承关系 2.有方法重写 3.有父类引用指向子类对象 三.编译运行原理 1 ...
- B. Worms Codeforces Round #271 (div2)
B. Worms time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...