博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
非常正经的看毛片(?)
阅读量:7114 次
发布时间:2019-06-28

本文共 662 字,大约阅读时间需要 2 分钟。

#include
#include
#include
#include
#include
using namespace std;int t;char a[1000005],b[10005];int next[10005];int main(){ scanf("%d",&t); while(t--){ scanf("%s%s",b+1,a+1); int m=strlen(b+1); int n=strlen(a+1); for(int i=2,j=0;i<=m;i++){ while(j&&b[j+1]!=b[i]) j=next[j]; if(b[j+1]==b[i]) j++; next[i]=j; } int ans=0; for(int i=1,j=0;i<=n;i++){ while(j&&b[j+1]!=a[i]) j=next[j]; if(b[j+1]==a[i]) j++; if(j==m){ ans++; j=next[j]; } } printf("%d\n",ans); } return 0; }

  

转载于:https://www.cnblogs.com/paozi/p/7771853.html

你可能感兴趣的文章
sql server中如何连接表更新数据
查看>>
高精度之——模板
查看>>
android解析xml文件的方式(其一)
查看>>
正则表达式常用函数:匹配/查找替换/分割等
查看>>
Python科学计算 第二版
查看>>
【讲古堂】表达式求值
查看>>
[翻译]在objective c创建自定义collection view样式
查看>>
iOS去除数组中重复数据的几种方法
查看>>
存储知识整理
查看>>
C Primer Plus 第9章 函数 9.1 函数概述
查看>>
Windows线程同步【2】临界区
查看>>
[转][开心学php100天]第三天:不羁的PHP文件操作
查看>>
将一段时间内没有数据的点用0填充
查看>>
c++构造函数详解
查看>>
ContentValues类和 Hashtable比较
查看>>
Php对python模块的调用
查看>>
composer 安装
查看>>
org.apache.spark.streaming.dstream.MappedDStream@5a69b104 has not been initialized
查看>>
linux shell 中判断字符串为空的正确方法
查看>>
致敬Linux系统
查看>>