十分暴力的KMP,枚举左端点,在向右侧推进的同时,取较小的la保证条件,n方暴力
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define inf 0x3fffffff
using namespace std;
const int N=;
char s[N];int l,k,nxt[N],la[N],ans;
int main(){
freopen("3620.in","r",stdin);
freopen("3620.out","w",stdout);
scanf("%s",s+);l=strlen(s+);scanf("%d",&k);ans=;
rep(i,,l){
nxt[i]=i-,la[i]=inf;
rep(ii,i,l-){
int j=nxt[ii];while(j>=i&&s[ii+]!=s[j+])j=nxt[j];
if(s[ii+]==s[j+]) ++j;nxt[ii+]=j; if(nxt[ii+]-i+<k)la[ii+]=inf;else{
la[ii+]=min(la[nxt[ii+]],nxt[ii+]);
if(la[ii+]-i+<=(ii+-i)>>) ++ans;}
}
}
printf("%d",ans); return ;
}