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 ,哈希树的更多相关文章

  1. hdu 1800 Flying to the Mars

    Flying to the Mars 题意:找出题给的最少的递增序列(严格递增)的个数,其中序列中每个数字不多于30位:序列长度不长于3000: input: 4 (n) 10 20 30 04 ou ...

  2. HDU 1800——Flying to the Mars——————【字符串哈希】

    Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  3. HDU 1800 Flying to the Mars Trie或者hash

    http://acm.hdu.edu.cn/showproblem.php?pid=1800 题目大意: 又是废话连篇 给你一些由数字组成的字符串,判断去掉前导0后那个字符串出现频率最高. 一开始敲h ...

  4. --hdu 1800 Flying to the Mars(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Ac code: #include<stdio.h> #include<std ...

  5. HDU - 1800 Flying to the Mars 【贪心】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1800 题意 给出N个人的 level 然后 高的level 的 人 是可以携带 比他低level 的人 ...

  6. hdu 1800 Flying to the Mars(简单模拟,string,字符串)

    题目 又来了string的基本用法 //less than 30 digits //等级长度甚至是超过了int64,所以要用字符串来模拟,然后注意去掉前导零 //最多重复的个数就是答案 //关于str ...

  7. 杭电 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 ...

  8. HDOJ.1800 Flying to the Mars(贪心+map)

    Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...

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

随机推荐

  1. linux进程状态详解(转)

    Linux是一个多用户,多任务的系统,可以同时运行多个用户的多个程序,就必然会产生很多的进程,而每个进程会有不同的状态.  在下文将对进程的 R.S.D.T.Z.X 六种状态做个说明. PROCESS ...

  2. Spring4整合Hibernate5时不能自动生成表结构

    © 版权声明:本文为博主原创文章,转载请注明出处 1.问题描述: Spring4整合Hibernate5时,不再使用hibernate.cfg.xml,将其内容整合到Spring配置文件中,启动后不能 ...

  3. PAT 1001. A+B Format(水题)

    #include<cstdio> #include<cstring> using namespace std; char s[10]; int main() { int a,b ...

  4. hiho1080 更为复杂的买卖房屋姿势

    题目链接: hihocoder1080 题解思路: 题目中对区间改动有两个操作: 0   区间全部点添加v 1   区间全部点改为v easy想到应该使用到两个懒惰标记  一个记录替换  一个记录增减 ...

  5. Python内置函数之range()

    range(stop)range(start,stop[,step]) 返回一个range对象,第三个参数的含义为:间隔的个数. range对象同时也是可迭代对象. >>> isin ...

  6. [译]GLUT教程 - 位图和正交投影视图

    Lighthouse3d.com >> GLUT Tutorial >> Fonts >> Bitmap Fonts and Orthogonal Projecti ...

  7. nginx 常见参数以及重定向参数配置

    nginx 各参数翻译,作用 $arg_PARAMETER #这个变量包含GET请求中,如果有变量PARAMETER时的值. $args #这个变量等于请求行中(GET请求)的参数,例如foo=123 ...

  8. vs2013中opencv的配置

    下面开始介绍如何配置,我用的系统是win8.1 64位系统,vs用的是vs3013 ultimate,先到官网下载opencv 我用的的版本是最新的版本3.0 ALPHA,下载下来直接执行即可,实际上 ...

  9. python 装饰器 (个人理解就是前置的内建函数)

    感谢有篇文件详细介绍[简单 12 步理解 Python 装饰器]http://python.jobbole.com/85056/ 1.首先介绍内建函数 2.转换为装饰器 3.执行顺序 4.装饰器实用

  10. ProjectManager Beta 7 项目管理器发布

    上次在Alpha阶段有一个可用版本Alpha 8也在这个博客发布了,传送:http://www.cnblogs.com/deali/p/ProjectManager.html ProjectManag ...