lyhqwq @ 2023-04-15 21:45:09
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=105;
const long double eps=1e-4;
int n;
long double a[N][N],b[N];
long double x[N];
int f=1;
void Gauss(){
for(int j=1;j<=n;j++){
if(fabs(a[j][j])<eps){
int Maxi=j;
for(int i=j+1;i<=n;i++){
if(fabs(a[i][j])>=fabs(a[Maxi][j])){
Maxi=i;
}
}
if(Maxi==j){
continue;
}
for(int k=1;k<=n;k++) swap(a[j][k],a[Maxi][k]);
swap(b[j],b[Maxi]);
}
for(int i=j+1;i<=n;i++){
if(fabs(a[i][j])<eps) continue;
long double tmp=a[i][j];
for(int k=j;k<=n;k++){
a[i][k]/=tmp;
a[i][k]*=a[j][j];
a[i][k]-=a[j][k];
}
b[i]/=tmp;
b[i]*=a[j][j];
b[i]-=b[j];
}
}
for(int i=n;i>=1;i--){
long double sum=b[i];
for(int j=n;j>i;j--){
sum-=x[j]*a[i][j];
}
if(fabs(a[i][i])<eps){
if(fabs(sum)<eps){
f=0;
}
else{
puts("-1");
exit(0);
}
}
x[i]=sum/a[i][i];
}
}
signed main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=n;j>=1;j--) scanf("%Lf",&a[i][j]);
scanf("%Lf",&b[i]);
}
Gauss();
if(!f){
printf("%d\n",f);
return 0;
}
for(int i=n;i>=1;i--){
if(fabs(x[i])<eps) printf("x%d=0.00\n",n-i+1);
else printf("x%d=%.2Lf\n",n-i+1,x[i]);
}
return 0;
}