标签:void mat show == https bsp def ++ ble
不开ll 40分 WA了4发,一脸懵逼,模数明明那么小0.0
最后开ll过了 emmm,一直以为自己写错了
#include <cstdio> #include <cmath> #include <algorithm> using namespace std; #define ll long long #define re register const int p=9999973; void read(int &a) { a=0; int d=1; char ch; while(ch=getchar(),ch>‘9‘||ch<‘0‘) if(ch==‘-‘) d=-1; a=ch^48; while(ch=getchar(),ch>=‘0‘&&ch<=‘9‘) a=(a<<3)+(a<<1)+(ch^48); a*=d; } void write(int x) { if(x<0) putchar(45),x=-x; if(x>9) write(x/10); putchar(x%10+‘0‘); } ll f[105][105][105]; ll C(int x){return (1ll*x*(x-1)/2)%p;} int main() { int n,m; read(n); read(m); f[0][0][0]=1; for(re int i=1;i<=n;i++) for(re int j=0;j<=m;j++) for(re int k=0;k<=m-j;k++) { f[i][j][k]=f[i-1][j][k]; if(k>=1) f[i][j][k]=(f[i][j][k]+f[i-1][j+1][k-1]*(j+1))%p; if(j>=1) f[i][j][k]=(f[i][j][k]+f[i-1][j-1][k]*(m-j+1-k))%p; if(j>=2) f[i][j][k]=(f[i][j][k]+f[i-1][j-2][k]*C(m-j+2-k))%p; if(k>=1) f[i][j][k]=(f[i][j][k]+f[i-1][j][k-1]*j*(m-j-k+1))%p; if(k>=2) f[i][j][k]=(f[i][j][k]+f[i-1][j+2][k-2]*C(j+2))%p; } ll ans=0; for(re int i=0;i<=m;i++) for(re int j=0;j<=m;j++) (ans+=f[n][i][j])%=p; printf("%lld",ans); return 0; }
标签:void mat show == https bsp def ++ ble
原文地址:https://www.cnblogs.com/acm1ruoji/p/10837855.html