题意
题解
我太菜了……
看官方题解吧:
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL maxn=405, MOD=998244353;
int n,m,w[maxn];
LL p[maxn][maxn],f[maxn][maxn];
int main(){
freopen("uoj311.in","r",stdin);
freopen("uoj311.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&w[i]);
for(int i=1;i<=n;i++){
p[i][0]=1;
for(int j=1;j<=n;j++) p[i][j]=p[i][j-1]*w[i]%MOD;
}
for(int i=0;i<=n;i++) f[1][i]=p[1][max(0,i-m+1)];
for(int i=2;i<=n;i++)
for(int j=0;j<=n;j++){
f[i][j]=f[i-1][j];
for(int k=1;k<=j;k++){
int t=max(0,m-max(0,m-k)-max(0,m-(j-k+1)));
(f[i][j]+=f[i-1][k-1]*p[i][t]%MOD*f[i][j-k]%MOD)%=MOD;
}
}
printf("%lld\n",f[n][n]);
return 0;
}