[数据删除] 的树 [树形dp]
设 表示 个节点, 深度不超过 的构成树的方案数, 枚举根节点编号 次大 子树大小转移,
#include<bits/stdc++.h>
#define reg register
int read(){
char c;
int s = 0, flag = 1;
while((c=getchar()) && !isdigit(c))
if(c == '-'){ flag = -1, c = getchar(); break ; }
while(isdigit(c)) s = s*10 + c-'0', c = getchar();
return s * flag;
}
const int maxn = 505;
const int mod = 998244353;
int N;
int K;
int C[maxn][maxn];
int F[maxn][maxn];
bool vis[maxn];
int main(){
freopen("a.in", "r", stdin);
N = read(), K = read();
C[0][0] = 1;
for(reg int i = 1; i <= N; i ++){
C[i][0] = 1;
for(reg int j = 1; j <= i; j ++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
}
for(reg int i = 1; i <= K; i ++) vis[read()] = 1;
for(reg int i = 1; i <= N; i ++) F[1][i] = 1;
if(!vis[N])
for(reg int i = 2; i <= N; i ++)
for(reg int j = 1; j <= N; j ++)
for(reg int k = 1; k <= i; k ++){
if(vis[k]) continue ;
int add = 1ll*F[k][j-1]*F[i-k][j]%mod*C[i-2][k-1]%mod;
F[i][j] = (F[i][j] + add) % mod;
}
int L = read(), R = read();
for(reg int i = L; i <= R; i ++) printf("%d\n", (F[N][i] - F[N][i-1] + mod) % mod);
return 0;
}