POJ-3461-Oulipo
来源:互联网 发布:js跳转微信打开链接 编辑:程序博客网 时间:2024/06/06 09:10
ACM模版
描述
题解
代码
#include <iostream>const int MAXN = 1e4 + 10;const int MAXM = 1e6 + 10;void KMP_Pre(char x[], int m, int next[]){ int i = 0, j = next[0] = -1; while (i < m) { while (-1 != j && x[i] != x[j]) { j = next[j]; } next[++i] = ++j; }}int n;int nxt[MAXN];char W[MAXN];char T[MAXM];int KMP_Count(char x[], int m, char y[], int n){ int i, j, ret = 0; KMP_Pre(x, m, nxt); i = j = 0; while (i < n) { while (-1 != j && y[i] != x[j]) { j = nxt[j]; } i++; j++; if (j >= m) { ret++; j = nxt[j]; } } return ret;}int main(int argc, const char * argv[]){ scanf("%d", &n); while (n--) { scanf("%s%s", W, T); int m = (int)strlen(W); int n = (int)strlen(T); printf("%d\n", KMP_Count(W, m, T, n)); } return 0;}
阅读全文
0 0
- POJ 3461 Oulipo
- POJ-3461 Oulipo
- poj 3461 Oulipo
- poj 3461 Oulipo(KMP)
- poj 3461 Oulipo
- POJ-3461-Oulipo
- POJ 3461 Oulipo(KMP)
- POJ 3461 Oulipo
- POJ 3461 Oulipo
- POJ 3461 Oulipo
- POJ 3461 Oulipo---kmp
- POJ 3461 Oulipo KMP
- poj-Oulipo -3461
- POJ 3461 Oulipo
- POJ 3461 Oulipo
- POJ 3461 Oulipo
- poj 3461 Oulipo
- poj 3461 Oulipo
- iOS内存浅谈
- Java_2017.10.09
- Uncaught Error: Error calling method on NPObject.
- 十图详解tensorflow数据读取机制(附代码)
- C++一本通题库1024
- POJ-3461-Oulipo
- 什么是进程?什么是线程?进程与线程有何区别?
- C++一本通题库1025
- Class.forName(String className) 实例化对象问题
- 045 中值定理总结(罗尔定理,拉格朗日定理,柯西定理,泰勒公式)及型一二三四五
- 霍夫曼编码
- 数据结构之顺序队列(循环队列)
- POJ1724 ROADS 解题报告【最短路/SPFA】
- bzoj 3033: 太鼓达人 欧拉图+dfs