[AT4362] [ARC102C] Stop. Otherwise...
首先考虑对于单个
对于点数
-
- 当
x-i=i 的时候,点数集合中只能出现至多一个i 。 -
接下来考虑
设
同样的,设
上述两个
接着对于每一个
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 2e3 + 5;
const LL MOD = 998244353;
int n, m;
LL f[maxn][maxn], g[maxn][maxn];
int main() {
scanf("%d%d", &m, &n);
f[0][0] = g[0][0] = 1;
LL s0, s1;
for (int i = 1; i <= m; i++) {
s0 = s1 = 0;
for (int j = 0; j <= n; j++)
f[i][j] = (f[i - 1][j] + s0 * 2 % MOD) % MOD,
s0 = (s0 + f[i - 1][j]) % MOD,
g[i][j] = (g[i - 1][j] + (j > 0 ? g[i][j - 1] : 0)) % MOD;
}
for (int i = 2; i <= (m << 1); i++) {
int c1 = 0, c2 = (i % 2 == 0), c3; LL ans = 0;
for (int j = 1; j <= m; j++) c1 += (i - j > m || i - j <= 0);
c3 = (m - c1 - c2) >> 1;
for (int j = 0; j <= n; j++) ans = (ans + f[c3][j] * g[c1][n - j] % MOD) % MOD;
if (c2) for (int j = 0; j < n; j++) ans = (ans + f[c3][j] * g[c1][n - j - 1] % MOD) % MOD;
printf("%lld\n", ans);
}
return 0;
}