CrTsIr400 @ 2023-07-11 15:25:00
什么回事呢,能否公开数据
#include<bits/stdc++.h>
#define fo(i,a,b) for(I i=a;i<=b;++i)
#define fd(i,a,b) for(I i=a;i>=b;--i)
using namespace std;typedef int I;typedef long long LL;const I inf=0x3f3f3f3f;I FL,CH;template<typename T>void in(T&a){for(FL=1;!isdigit(CH)&&CH!=EOF;CH=getchar())FL=(CH=='-')?-1:1;for(a=0;isdigit(CH);CH=getchar())a=a*10+CH-'0';a*=FL;}template<typename T,typename...Args>void in(T&a,Args&...args){in(a);in(args...);}
const I N=52;typedef double DB;
vector<DB>a[N];I n;
I main(){in(n);
fo(i,1,n){
a[i].resize(n+1);
fo(j,1,n)in(a[i][j]);
in(a[i][0]);
}I p=1;
fo(i,1,n){
I q=p;
fo(j,p+1,n)if(fabs(a[j][i])>fabs(a[q][i]))q=j;
if(fabs(a[q][i])<1e-8)continue;
swap(a[p],a[q]);
fo(j,1,n)if(j^p){
DB mu=a[j][i]/a[p][i];
fo(k,i,n)a[j][k]-=mu*a[i][k];
a[j][0]-=mu*a[i][0];
}
++p;
}if(p<=n){
fo(i,p,n)if(fabs(a[i][0])>1e-8)return puts("-1"),0;
return puts("0"),0;
}fo(i,1,n){printf("x%d=",i);
if(fabs(a[i][0]/a[i][i])<1e-8)puts("0.00");
else printf("%.2lf\n",a[i][0]/a[i][i]);}
return 0;
}