| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 39772 | 22fhq | 【S】T2 | C++ | Accepted | 70 | 977 MS | 226484 KB | 1576 | 2026-01-31 19:56:11 |
#include<bits/stdc++.h> #define int long long #define db long double using namespace std; #define y0 jp8akioi #define y1 jbhakioi #define yn baka24akioi #define fls fflush(stdout) inline void read(int &x){x=0;char c=getchar();bool neg=0;while(!isdigit(c)){if(c=='-')neg=1;c=getchar();}while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();if(neg)x=-x;} #define read2(a,b) ::read(a),::read(b) #define read3(a,b,c) read2(a,b),::read(c) #define read4(a,b,c,d) read3(a,b,c),::read(d) #define read5(a,b,c,d,e) read4(a,b,c,d),::read(e) #define read6(a,b,c,d,e,f) read5(a,b,c,d,e),::read(f) constexpr int mod=998244353; int n,m,dp[3005][3005],fact[10000005],inv[10000005]; inline int A(int x,int y){ return fact[x]*inv[x-y]%mod; } void slv(){ read2(n,m); dp[1][1]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[i+1][j]+=dp[i][j]*A(n*m-i*j-1,j-1)%mod*j%mod; dp[i][j+1]+=dp[i][j]*A(n*m-i*j-1,i-1)%mod*i%mod; } } int ans=dp[n][m]; for(int i=1;i<=n;i++)ans*=i,ans%=mod; for(int i=1;i<=m;i++)ans*=i,ans%=mod; cout<<ans<<endl; } signed main(){ fact[0]=1; for(int i=1;i<=10000000;i++)fact[i]=fact[i-1]*i%mod; auto qp=[](int x,int y){ int res=1; while(y){ if(y&1)res*=x,res%=mod; x*=x,x%=mod; y>>=1; } return res; }; inv[10000000]=qp(fact[10000000],mod-2); for(int i=9999999;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod; // int T;read(T);while(T--) slv(); return 0; }