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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| #include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdlib> #include<vector> #include<cstdio> #include<cmath> #include<queue> using namespace std; typedef long long LL; inline const LL Get_Int() { LL num=0,bj=1; char x=getchar(); while(x<'0'||x>'9') { if(x=='-')bj=-1; x=getchar(); } while(x>='0'&&x<='9') { num=num*10+x-'0'; x=getchar(); } return num*bj; } const int maxn=105; const LL mod=998244353; struct Matrix { LL n,m,a[maxn][maxn]; Matrix(LL n,LL m) { init(n,m); } Matrix(LL n,LL m,char E) { init(n,m); for(int i=1; i<=n; i++)a[i][i]=1; } void init(LL n,LL m) { this->n=n; this->m=m; memset(a,0,sizeof(a)); } LL* operator [] (const LL x) { return a[x]; } Matrix operator * (Matrix& b) { Matrix c(n,b.m); for(int i=1; i<=n; i++) for(int j=1; j<=b.m; j++) for(int k=1; k<=m; k++) c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod; return c; } void operator *= (Matrix& b) { *this=*this*b; } Matrix operator ^ (LL b) { Matrix ans(n,m,'e'),a=*this; while(b>0) { if(b&1)ans=ans*a; a*=a; b>>=1; } return ans; } }; LL Quick_Pow(LL a,LL b) { LL ans=1; while(b>0) { if(b&1)ans=ans*a%mod; a=a*a%mod; b>>=1; } return ans; } LL n,m,p,q,C[105][105],g[105][105]; int main() { n=Get_Int(); m=Get_Int(); p=Get_Int(); q=Get_Int(); C[0][0]=1; for(int i=1; i<=100; 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; } g[0][0]=1; for(int i=1; i<=n; i++) for(int k=1; k<=p; k++) g[i][k]=(k*g[i-1][k]%mod+(p-(k-1))*g[i-1][k-1]%mod)%mod; Matrix B(p,p); for(LL S=1; S<=p; S++) for(LL T=1; T<=p; T++) { LL tmp=0; for(int w=0; w<=min(min(S,T),min(p,S+T-q)); w++)tmp=(tmp+C[T][w]*C[p-T][S-w]%mod)%mod; tmp=tmp*g[n][S]%mod*Quick_Pow(C[p][S],mod-2)%mod; B[S][T]=tmp; } B=B^(m-1); LL ans=0; for(int i=1; i<=p; i++) for(int j=1; j<=p; j++) ans=(ans+B[j][i]*g[n][i]%mod)%mod; printf("%lld\n",ans); return 0; }
|