hdoj 1686 Oulipo
来源:互联网 发布:宁波行知小学总课表 编辑:程序博客网 时间:2024/04/25 17:16
题目链接:Oulipo
题目大意:给你一个模式串和原串,计算模式串在原串里面出现的次数
题目思路:直接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;}
阅读全文
0 0
- HDOJ 1686 Oulipo
- HDOJ 1686 Oulipo KMP
- HDOJ-1686 Oulipo ---KMP
- HDOJ Oulipo 1686【KMP】
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo【kmp】
- hdoj 1686 Oulipo
- hdoj-1686 Oulipo
- HDOJ 1686 Oulipo(KMP)
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo【kmp】
- HDOJ 1686 Oulipo
- hdoj--1686--Oulipo
- hdoj 1686 Oulipo【KMP】
- hdoj 1686 Oulipo
- hdoj 1686 Oulipo
- hdoj-1686Oulipo(Kmp)
- Notepad++配色
- C语言const:禁止修改变量的值
- 使用python进行数据分析介绍及部分教程
- Android 磁场传感器 地磁倾角计算 SensorManager.getInclination方法
- 为什么canvas绘制的线条会模糊、有锯齿?
- hdoj 1686 Oulipo
- 软件光栅化渲染器(九)
- Windows上部署Jenkins遇到的问题
- byte为何范围是-128~127
- 编程第五十六天
- 【Leetcode】389. Find the Difference
- 三维网格精简算法(Quadric Error Metrics)附源码(一)
- 双队列=>栈
- 记录一下这几天eclipse建立maven工程遇到的问题