codeforces625BWar of the Corporations
来源:互联网 发布:仿08影院模板源码 编辑:程序博客网 时间:2024/06/07 19:44
这题就是问你一串字符串里包含几个字串
kmp一下就好了
/* ***********************************************Author :yzkAcceptedCreated Time :2016/2/7 18:20:38TASK :ggfly.cppLANG :C++************************************************ */#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>using namespace std;typedef __int64 ll;char s[100050],str[100050];int nnext[2005];int pd(char *s1,char *s2){ int n,m,i,j,num=0;n=strlen(s1);m=strlen(s2);i=0,j=-1;memset(nnext,-1,sizeof(nnext));while(i<m){if(j==-1 || s2[i]==s2[j]){i++;j++;nnext[i]=j;}else j=nnext[j];}i=0;j=0;while(i<n && j<m){if(j==-1 || s1[i]==s2[j]){i++,j++;if(j==m){num++;j=0;}}elsej=nnext[j];}return num;}int main(){ int n,m,i,j,ans; scanf("%s",s); scanf("%s",str);printf("%d\n",pd(s,str)); return 0;}
0 0
- codeforces625BWar of the Corporations
- B. War of the Corporations
- coderforces342B. War of the Corporations【strstr】
- Codeforces 625B - War of the Corporations
- cf#342-B - War of the Corporations
- CodeForces 625B War of the Corporations
- CodeForces 625B - War of the Corporations
- Codeforces 625B War of the Corporations 【暴力】
- Codeforces Round #342 (Div. 2)--B. War of the Corporations
- Codeforces Round #342 (Div. 2)-B. War of the Corporations
- CodeForces 625 B. War of the Corporations(水~)
- cf 625 b.War of the Corporations (字符串)
- CodeForces 625B War of the Corporations(KMP)
- 【38.02%】【codeforces 625B】War of the Corporations
- War of the Corporations(字符串子串的查找)
- Codeforces Round #342 (Div. 2)-B. War of the Corporations(模拟)
- Codeforces Round #342 (Div. 2) 625B War of the Corporations(stl)
- Codeforces 625B War of the Corporations (字符串匹配题目)
- 约会(并查集)
- 两个堆栈m和n(m<n)模拟一个队列,容量为m+m
- 【ADO】回头复习,总是会有新的收获
- 使用FormData,进行Ajax请求并上传文件
- Mac终端ls显示不同文件类型的颜色
- codeforces625BWar of the Corporations
- CodeForces 617 A. Elephant(水~)
- 百度基础架构部-分布式存储组面试经历
- ubuntu下iptables的配置
- 【poj3009】curling 2.0——dfs
- 软件工程文档总结
- 项目记录23--unity-tolua框架MediatorManager
- 单词统计(未完成)
- php如何实现验证码