inlinedoubledeterminant(double (*A)[maxn],int n) { for (int i=1,c=1,j;i<=n;++i) { for (j=c;j<=n && fabs(A[j][i])<eps;++j); if (j==n+1) continue; for (int k=1;k<=n;++k) swap(A[c][k],A[j][k]); for (int j=c+1;j<=n;++j) if (fabs(A[j][i])>eps) { double t=A[j][i]/A[c][i]; for (int k=i;k<=n;++k) A[j][k]-=A[c][k]*t; } ++c; } double ans=1; for (int i=1;i<=n;++i) ans*=A[i][i]; returnfabs(ans); }
intmain() { int n; scanf("%d",&n); for (int i=1;i<=n;++i) for (int j=1;j<=n;++j) { scanf("%lf",&G[i][j]); if (G[i][j]==1) G[i][j]-=eps; } double prod=1; for (int i=1;i<=n;++i) for (int j=1;j<i;++j) prod*=1-G[i][j]; for (int i=1;i<=n;++i) for (int j=1;j<=n;++j) if (i!=j) G[i][j]=G[i][j]/(1-G[i][j]),G[i][i]+=G[i][j],G[i][j]=-G[i][j]; printf("%.10lf",prod*determinant(G,n-1));// BZOJ SPJ好像挂了,必须输出10位小数才能过... }