标签:ace end src define long 技术 upload swa scan
#include <bits/stdc++.h> using namespace std; #define N 300005 #define go(i,a,b) for(int i=(a);i<=(b);i++) #define inf 0x3f3f3f3f #define mod 998244353 #define ll long long int ny(int x){return x==1?1:1ll*ny(mod%x)*(mod-mod/x)%mod; } ll a[410][410],jx[N]; int in[N],out[N],n; ll det(int n)//求前n行n列的行列式的值 { go(i,1,n)go(j,1,n)a[i][j]=(a[i][j]%mod+mod)%mod; ll ret=1; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) while(a[j][i]) { ll t=a[i][i]/a[j][i]; for(int k=i;k<=n;++k) a[i][k]=((a[i][k]-a[j][k]*t)%mod+mod)%mod; for(int k=i;k<=n;++k) swap(a[i][k],a[j][k]); ret=-ret; } if(!a[i][i]) return 0; ret=ret*a[i][i]%mod; } ret=(ret%mod+mod)%mod; return ret; } int x,cas=1; int main() { jx[0]=1;go(i,1,N-1)jx[i]=jx[i-1]*i%mod; while(scanf("%d",&n)!=EOF){ ll ans=1; go(i,0,n)go(j,0,n)a[i][j]=out[i]=in[i]=0; go(i,1,n){ go(j,1,n){ scanf("%d",&x); a[i][j]-=x; a[j][j]+=x; in[i]+=x; out[j]+=x; if(x)(ans*=ny(jx[x]))%=mod; } (ans*=(jx[in[i]-1]+mod)%mod)%=mod; } int fl=1; go(i,1,n)if(in[i]!=out[i])fl=0; (ans*=det(n-1))%=mod; // cout<<ans<<endl; printf("Case #%d: %lld\n",cas++,ans*in[1]*fl%mod); } return 0; }
标签:ace end src define long 技术 upload swa scan
原文地址:https://www.cnblogs.com/SDUTNING/p/11543706.html