这道题我WA了好几遍,很平常的对于KMP的应用,一开始还T了,后来发现自己好像写了假的KMP,改了一下就A掉了,因为递归的话可能被卡成n^2,所以要递推出解,一种很巧妙的写法就可以直接递推出解(其实KMP本来就是这么写的。。)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define N 1000005
int dp[N],t,next[N],n,num[N];
char s[N];
inline void KMP(