
字符串比较
是驊哥啊
这个作者很懒,什么都没留下…
展开
-
哈希函数 (处理字符串)
POJ 2752: Seek the Name, Seek the Fam problem: http://poj.org/problem?id=2752 把每个前缀和后缀相同的位置都输出 Input: ababcababababcabab aaaaa Output: 2 4 9 18 1 2 3 4 5 Code: #include<iostream> #include<cstring> #include<cstdio> #define rep(i,s,n)原创 2021-08-24 09:04:17 · 187 阅读 · 0 评论 -
KMP
void get_next() { next_[0]=-1; i=0,k=-1; while(i<m) { if(k == -1 || b[i] == b[k]) next_[++i] = ++k; else k = next_[k]; } } int kmp() { n = strlen(a); m = strlen(b); get_next(); i=0,j=0; count=0; while(i<n) { if(j == -1 || a[i] == b原创 2021-08-17 14:53:06 · 97 阅读 · 0 评论