hdoj 1686 Oulipo
2017-05-30 22:25
211 查看
题目链接:Oulipo
题目大意:给你一个模式串和原串,计算模式串在原串里面出现的次数
题目思路:直接KMP就好
题目大意:给你一个模式串和原串,计算模式串在原串里面出现的次数
题目思路:直接KMP就好
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6+10; int n,Next[maxn]; char mo[maxn],str[maxn]; int main(){ scanf("%d",&n); while(n--){ memset(Next,-1,sizeof(Next)); scanf("%s%s",mo,str); int i = 0,j = -1,len = strlen(mo); while(i < len){ if(j == -1||mo[i] == mo[j]) Next[++i] = ++j; else j = Next[j]; } int ans = 0,len1 = strlen(str); i = j = 0; while(i < len1){ if(j == -1||str[i] == mo[j]) ++i,++j; else j = Next[j]; if(j == len) ans++; } printf("%d\n",ans); } return 0; }
相关文章推荐
- hdoj 1686 Oulipo 【kmp(模板)】
- hdoj-1686 Oulipo(Kmp)
- HDOJ 题目1686 Oulipo(KMP)
- hdoj 1686 Oulipo【kmp】
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo【kmp】
- HDOJ 1686 POJ 3461 Oulipo kmp
- [HDOJ1686]Oulipo
- HDOJ 1686 Oulipo
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo(KMP算法)
- hdoj 1686 Oulipo【求一个字符串在另一个字符串中出现次数】
- HDOJ Oulipo 1686【KMP】
- HDOJ 1686 Oulipo KMP
- HDOJ-1686 Oulipo ---KMP
- hdoj 1686Oulipo (简单KMP匹配)
- 【HDOJ】1686 Oulipo
- hdoj 1686 Oulipo 【求一个串在另一串的出现次数】【KMP】