提交时间:2024-10-04 19:32:48
运行 ID: 33284
#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]; int n; int m; inline int quickpow(int x,int y){ int tot=1; while(y){ if(y&1) tot=tot%md*x%md; x=x%md*x%md; y=y>>1; } return tot; } inline int C(int x,int y){ if(x<0||y<0) return 0; if(x<y) return 0; else return (pre[x]%md*inv[y]%md*inv[x-y]%md+md)%md; } signed main(){ ios::sync_with_stdio(false); cin>>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; 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(n,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; } } cout<<ANS%md<<endl; return 0; }