这个题解错了网上还没有题解 囧
fi = (i%2)? 1 : -1
Fn = (n+m−1m−1) - ∑ni=0 ∑m−1j=1 (n−i∗(j+1)+m−2 m−2) * (m−1 j)*fj
Fn *= m
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const int MOD = 998244353;
ll C[1005][1005];
int main(){
int n,m;
C[0][0] = 1;
for(int i = 1; i <= 1000; ++i) {
C[i][0] = C[i][i] = 1;
for(int j = 1; j < i; ++j) {
C[i][j] = (C[i-1][j-1]+C[i-1][j]) %MOD;
}
}
while(~scanf("%d %d",&n,&m)) {
ll ans = C[n+m-1][m-1];
for(int i = 0; i <= n; ++i) {
int fl = -1;
for(int j = 1; j <= m-1; ++j) {
if(n-i*(j+1) < 0) continue;
int tt = n-i*(j+1);
ans = (ans + fl*C[tt+m-2][m-2]*C[m-1][j]%MOD + MOD) %MOD;
fl *= -1;
}
}
printf("%lld\n",ans*m%MOD);
}
return 0;
}