1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| const int N=2030,INF=1e9+10,P=998244353;
int n,m; int dp[N][N],ans;
ll F(int n,int m){ if(m<0) return 0; return m==0?1:(dp[n][m]-dp[n][m-1]+P)%P; } int S[N],T[N];
void Calc(){ rep(i,1,n-1) { int s=0; rep(j,1,m-1) { s=(s+1ll*F(j,i)*dp[m-j][i-1])%P; ans=(ans+1ll*s*F(m-j,n-i)%P*dp[j][n-i-1])%P; } } }
int main(){ dp[0][0]=1; rep(i,1,N-1){ rep(j,0,N-1) { if(j) dp[i-1][j]+=dp[i-1][j-1],Mod1(dp[i-1][j]); dp[i][j]=dp[i-1][j]; } } n=rd(),m=rd(); Calc(),swap(n,m),Calc(); rep(i,1,n-1) { int s=0; rep(j,1,m-1) { s=1ll*F(j,i)*dp[m-j][i-1]%P; ans=(ans-1ll*s*F(m-j,n-i)%P*dp[j][n-i-1])%P; } } Mod2(ans); printf("%d\n",ans*2%P); }
|