去看STDCALL的题解吧
#include<cstdio> #include<cctype> #define mod 9999973 inline long long read(){ long long num=0,f=1; char ch=getchar(); while(!isdigit(ch)){ if(ch=='-') f=-1; ch=getchar(); } while(isdigit(ch)){ num=num*10+ch-'0'; ch=getchar(); } return num*f; } int C(int num){ return num*(num-1)/2; } long long f[102][102][102]; long long ans; int main(){ int n=read(),m=read(); f[0][0][0]=1; for(int i=0;i<=n;++i) for(int j=0;j<=m;++j) for(int k=0;j+k<=m;++k){ if(!f[i][j][k]) continue; f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod; if(m-j-k>0) f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k]*(m-j-k))%mod; if(j) f[i+1][j-1][k+1]=(f[i+1][j-1][k+1]+f[i][j][k]*j)%mod; if(m-j-k>1) f[i+1][j+2][k]=(f[i+1][j+2][k]+f[i][j][k]*C(m-j-k)) %mod; if(m-j-k&&j) f[i+1][j][k+1]=(f[i+1][j][k+1]+f[i][j][k]*(m-j-k)*j)%mod; if(j>1) f[i+1][j-2][k+2]=(f[i+1][j-2][k+2]+f[i][j][k]*C(j))%mod; } for(int i=0;i<=m;++i) for(int j=0;i+j<=m;++j) ans=(ans+f[n][i][j])%mod; printf("%lld",ans); return 0; }