提交时间:2024-10-04 19:39:31
运行 ID: 33288
#include<bits/stdc++.h> using namespace std; const int N = 510,M = 1e5+10,md = 998244353; #define int long long int inv[N+M],pre[N+M],c[N]; int n; int m; inline int quickpow(int x,int y){ int tot=1; while(y){ if(y&1) tot=tot*x%md; x=x*x%md; y=y>>1; } return tot; } inline int C(int x,int y){ if(x<y||x<0||y<0) return 0; else return (pre[x]%md*inv[y]%md*inv[x-y]%md)%md; } signed main(){ scanf("%lld %lld",&n,&m); pre[0]=1; for(int i=1;i<=n+m;i++){ pre[i]=pre[i-1]*i%md; } inv[n+m]=quickpow(pre[n+m],md-2); for(int i=n+m-1;i>=0;i--){ inv[i]=inv[i+1]%md*(i+1)%md; } inv[0]=1; for(int i=0;i<=n;i++){ c[i]=C(n,i); } int ANS=0; for(int i=0;i<=m;i++){ int z=(2*m-2*i)%md*(2*m-2*i)%md*C(n+i-1,i)%md; for(int j=0;j<=n;j++){ int p=c[j]%md; int q=C(m-i-1,j-1)*C(n-j+m-i-1,m-i)%md; ANS=(ANS%md+z%md*p%md*q%md)%md; } } printf("%lld\n",ANS%md); return 0; }