POJ_3461-Oulipo
来源:互联网 发布:python源代码 编辑:程序博客网 时间:2024/06/06 00:50
//没啥好说的,KMP模板题
AC代码:
#include<stdio.h>#include<string.h>#define max 1000005char s[max];char t[max];int len1;int len2;int next[max];int sum;void get_next(){ int i=0; int j=-1; next[0]=-1; while(i<len2) { if(j==-1||t[i]==t[j]) { i++; j++; next[i]=j; } else { j=next[j]; } }}void kmp(){ int i=0; int j=0; while(i<len1) { if(j==-1||s[i]==t[j]) { i++; j++; } else { j=next[j]; } if(j==len2) { sum++; } }}int main(){ int x; scanf("%d",&x); while(x--) { scanf("%s%s",t,s); len1=strlen(s); len2=strlen(t); memset(next,0,sizeof(next)); sum=0; get_next(); kmp(); printf("%d\n",sum); } return 0;}
0 0
- POJ_3461-Oulipo
- POJ_3461 Oulipo 【KMP】
- poj_3461 Oulipo(KMP:找出所有模式串)
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- Oulipo
- 【C#】C#委托和事件的实例讲解
- 激活任务栏的托盘程序窗口[特殊情况下使用]
- 关闭patchoat
- IOS系统下(iPhone、iPad)滚动条不能用(失效)问题
- 单点故障--名词解释
- POJ_3461-Oulipo
- 全程解析Win7各个版本的主要区别
- c++11标准范围for语句的尝试
- 黑马程序员——java基础——反射机制的学习
- SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
- angular-ui-route遇到Error: fnPtr is not a function或Error: m is not a function
- HDU 4352 XHXJ's LIS (数位DP+状态压缩)
- 枚举进程的两种方式
- mybatis按时间查询oracle数据