POJ3461 KMP
来源:互联网 发布:爱思维尔数据库收费 编辑:程序博客网 时间:2024/06/02 08:22
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<algorithm>#include<set>#include<map>#include<queue>#include<vector>#include<stack>using namespace std;#define ll long long #define ull unsigned long long #define mxn 1002000#define eps 1e-8char t[mxn], w[mxn];int f[mxn];void getf() {int n = strlen( w );f[0] = f[1] = 0;for( int i = 1; i <= n; ++i ) {int j = f[i];while( j && w[j] != w[i] )j = f[j];f[i+1] = w[i] == w[j] ? j + 1 : 0;}}int find() {int n = strlen( t );int nw = strlen( w );getf();int j = 0;int ret = 0;for( int i = 0; i < n; ++i ) {while( j && t[i] != w[j] )j = f[j];if( t[i] == w[j] )j ++;if( j == nw )ret++;}return ret;}int main() {int cas; scanf( "%d", &cas ); while( cas-- ) { scanf( "%s", w ); scanf( "%s", t ); printf( "%d\n", find() ); } return 0;}
0 0
- poj3461(KMP)
- POJ3461 KMP
- KMP+poj3461
- poj3461 KMP
- poj3461 KMP
- poj3461 KMP
- POJ3461 KMP
- poj3461 KMP
- poj3461(kmp模版题)
- 【KMP】 poj3461 Oulipo
- poj3461 kmp 模板题
- POJ3461 KMP算法
- poj3461 KMP模板题
- 【KMP】Oulipo POJ3461
- POJ3461《Outplo》方法:KMP
- poj3461 Oulipo (kmp)
- poj3461之kmp入门
- [POJ3461] Oulipo[KMP基础]
- FileExists 文件是否存在
- Filter组件开发中的SDK基类分析
- 历届试题 错误票据
- 有用的小程序的总结
- Android--通知之Notification
- POJ3461 KMP
- android面试题
- 第三十九章续:区间最值RMQ问题
- 挖一口属于自己的井
- 自动识别输入的字符串并转换成可单击的超链接
- 几种网格平滑算法的实现
- 给Linux系统/网络管理员的nmap的29个实用例子
- --未打印分界线--
- 老照片回忆新中国最早的警花