hdu 1800 Flying to the Mars (字典树)
来源:互联网 发布:淘宝头条写手招募 编辑:程序博客网 时间:2024/05/16 10:03
1.死循环会给出The limit exceeded,while(scanf("%d",n))别忘了写!=EOF。
2.一种字符串加数字的操作,加几会把前面的字符消除几位。
#include<stdio.h>#include<string.h>#include<stdlib.h>typedef struct node{ struct node*next[10]; bool exist; int count;}*trie,node;trie root;int m;void creat(trie &p){ p=(trie)malloc(sizeof(node)); for(int i=0;i<10;i++) p->next[i]=0; p->exist=false; p->count=0;}void insert(trie p,char s[]){ int k=0 ; while(s[k]!='\0'){ if(!p->next[s[k]-'0']){ trie q; creat(q); p->next[s[k]-'0']=q; } p=p->next[s[k]-'0']; k++; } p->exist=true; p->count++; if(p->count>m) m=p->count;}int main(){ int n,i; char s[31]; while(scanf("%d",&n)!=EOF){ creat(root); m=0; for(i=0;i<n;i++){ scanf("%s",s); int j=0; while(s[j]=='0'){ /*又学会一种姿势*/ j++; } insert(root,s+j); } printf("%d\n",m); } return 0;}
阅读全文
0 0
- HDU 1800 Flying to the Mars(字典树)
- hdu 1800 Flying to the Mars (字典树)
- hdu 1800 Flying to the Mars(字典树)
- [字典树、map] HDU 1800 - Flying to the Mars
- hdu 1800 Flying to the Mars 字典树
- hdu 1800 Flying to the Mars 字典树
- hdu 1800 Flying to the Mars 字典树
- hdu 1800 Flying to the Mars(字典树统计)
- Flying to the Mars(字典树)
- hdu 1800 Flying to the Mars(HashMap水过,可用字典树)
- hdu 1800 Flying to the Mars(字典树||map||hash)
- 文章标题 HDU 1800:Flying to the Mars(字典树)
- 字典树水题Flying to the Mars HDU 1800
- HDU 1800 Flying to the Mars(字典树水题)
- hdu 1800 Flying to the Mars (trie树)
- HDU -- 1800 Flying to the Mars (Trie 树)
- HDU 1800-Flying to the Mars(trie树)
- 【字典树】 hdu1800 Flying to the Mars
- VLC架构及流程分析
- VPS、WMWarre和Docker的概念和区别
- aspx,ashx,ascx小结
- 讲讲Js中的函数
- Linux下信号通信实现A进程死循环输出A后被C进程处理输出C
- hdu 1800 Flying to the Mars (字典树)
- 【DP】CodeForces
- Linux五种IO模型性能分析
- 二分图最大匹配算法
- 深层神经网络——过拟合问题
- 在Python3.5下安装和测试Scrapy爬网站
- iOS 常见错误之 linker command failed with exit code 1 并且点不进去 解决方法
- JavaSE_JavaIO操作
- 线性回归模型之LinearRegression和SGDRegressor