感觉对了,但是 WA 4 个点
比如 https://www.luogu.com.cn/record/152560460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll m=998244353;
int n,w;
ll x,c=1,k,d;
char s[2000005];
int bd(char s[]) {
int p[2000005]={0};
for(int i=1;i<n;i++) {
int j=p[i-1];
while(j>0&&s[i]!=s[j]) j=p[j-1];
if(s[i]==s[j]) ++j;
p[i]=j;
}
return p[n-1];
}
bool chk(int i,int j){
for(int o=0;o<=w-1;o++) if(s[i+o]!=s[j+o]) return 0;
return 1;
}
ll po(ll a,ll b){
ll r=1;
while(b){
if(b&1) r=r*a%m;
a=a*a%m,b>>=1;
}
return r;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>k>>s,w=bd(s);
if(n%(n-w)==0) cout<<(po(2,k)*w%m+n-w)%m;
else{
for(int i=0;i+2*w-1<n;i+=w)
if(chk(0,i+w)) ++c;
else break;
d=n,x=1;
while(x<c&&k) d=(d+x*w%m)%m,x<<=1,--k;
if(k) d=(d+c*w%m*(k%m)%m)%m;
cout<<d;
}
return 0;
}