tjut 3460
来源:互联网 发布:2017怎么申请开淘宝店 编辑:程序博客网 时间:2024/06/05 09:18
#include"stdio.h" #include"string.h" #include"stdlib.h" struct dic { struct dic *child[26]; }; struct dic *root; int max; int ans; void insert(char *source) { struct dic *now,*newnode; int i,j; int len; len=strlen(source); max=max>len?max:len; now=root; for(i=0;i<len;i++) { if(now->child[source[i]-'a']!=NULL) now=now->child[source[i]-'a']; else { newnode=(struct dic*)malloc(sizeof(struct dic)); for(j=0;j<26;j++) newnode->child[j]=NULL; now->child[source[i]-'a']=newnode; now=newnode; } } } void count(struct dic *now) { int j; for(j=0;j<26;j++) { if(now->child[j]==NULL) continue; else { ans++; count(now->child[j]); } } } int main() { int n; int i,j; char str[55]; while(scanf("%d",&n)!=-1) { root=(struct dic *)malloc(sizeof(struct dic)); for(j=0;j<26;j++) root->child[j]=0; max=0; for(i=0;i<n;i++) { scanf("%s",str); insert(str); } ans=0; count(root); ans*=2; ans-=max; ans+=n; printf("%d\n",ans); } return 0; }
0 0
- tjut 3460
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- Activity
- For oracle databases, if the top showing the oracle database, then oracle process is using the top c
- 多态
- socket 通信关于bind那点事1
- 浏览器加载和渲染html的顺序
- tjut 3460
- Power of Four
- 搜索为了洗白的竞价排名 怎么就成了今天这种招黑模样
- 项目实战:自定义ListView、数据库操作和Activity交互
- 51nod oj 1241 特殊的排序 【排序之贪心】
- Android---------------->获取缓存大小和清除缓存功能
- Java虚拟机简介
- RenderWidget和RenderView的不同
- 函数指针 与 函数