字符串处理
文章平均质量分 51
进修中的涵涵涵
acm退役选手
acm icpc 金
dota爱好者
展开
-
UVA - 10282 Babelfish (字符串hash)
字符串hash模板题 字符串hash模板int get_hash(char *s) { int seed=131;//可以用其他代替 int hash=0; for(int i=0;s[i]!='\0';i++) { hash=hash*seed+(s[i]-'a'); } return (hash & 0x7FFFFFFF)%mod原创 2017-03-03 17:32:38 · 418 阅读 · 0 评论 -
UVA - 10391 Compound Words (字符串hash)
题意:找出由两个字符串拼起来的字符串输出 暴力搜索切点分开字符串,查找有没有两断都存在的 通过字符串hash散列 AC代码#include<stdio.h> #include<string.h> char a[120500][20]; int head[120500]; int next1[120500]; int get_hash(char *s) { int hash=0;原创 2017-03-03 17:37:38 · 463 阅读 · 0 评论 -
HDU - 1247 Hat’s Words(Trie 字典树)
之前用hash做过这题后面想一下其实字典树也是一样的 只要把hash的建立过程替换成建立字典树就可以了速度上更快一点 不过空间消耗大。 hash链接->hash AC代码字典树AC代码#include<stdio.h> #include<string.h> struct Trie { struct node { int flag; int nex原创 2017-03-13 16:51:35 · 379 阅读 · 0 评论 -
HDU 1358 Period (next跳表找最小循环节)KMP
Period HDU - 1358 For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That原创 2017-04-12 16:29:37 · 483 阅读 · 0 评论 -
HDU - 3746 Cyclic Nacklace (最小循环节KPM)
CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about how to原创 2017-04-12 15:46:47 · 834 阅读 · 0 评论 -
POJ - 2752 Seek the Name, Seek the Fame(前缀和后缀子串相同 KMP)
Seek the Name, Seek the Fame POJ - 2752 The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They see原创 2017-04-12 19:08:14 · 449 阅读 · 0 评论