#include<bits/stdc++.h> using DB = double; constint N = 100 + 100; const DB eps = 1e-8; int n; structMtx { DB x[N][N]; DB* operator [] (int id){ return x[id]; } } a; intguass(Mtx &x, int len)//注意传实参 { int i, j, k, t, now; for (i = now = 1; i <= len; ++i) { t = now; for (j = i; j <= len; ++j) if (fabs(x[j][i]) > fabs(x[t][i])) t = j; if (fabs(x[t][i]) < eps) continue; if (t != now) std::swap(x.x[t], x.x[now]); for (j = len + 1; j >= i; --j) x[now][j] /= x[now][i]; for (j = now + 1; j <= len; ++j) if (fabs(x[j][i])) for (k = len + 1; k >= i; --k) x[j][k] -= x[j][i] * x[now][k]; ++now; } if (now <= len) { for (i = now; i <= len; ++i) if (fabs(x[i][len + 1]) > eps) return-1; return len - now + 1; } for (i = len; i; --i) for (j = i + 1; j <= len; ++j) x[i][len + 1] -= x[i][j] * x[j][len + 1]; for (i = len; i; --i) if (fabs(x[i][len + 1]) < eps) x[i][len + 1] = 0; //防止出现-0.00 return0; } intmain() { scanf("%d", &n); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n + 1; ++j) scanf("%lf", &a[i][j]); if (!guass(a, n)) for (int i = 1; i <= n; ++i) printf("%.2lf\n", a[i][n + 1]); elseputs("No Solution"); return0; }
intqpow(int x, int y) { int res = 1; for (; y; y >>= 1, x = LL(x) * x % P) if (y & 1) res = LL(res) * x % P; return res; } voidadj(int &x){ x += (x >> 31) & P; } intguass(Mtx &x, int len)//进入前保证系数非负 { int i, j, k, now, t; for (i = now = 1; i <= len; ++i) { for (t = i; t <= len; ++t) if (x[t][i]) break; if (t > len) continue; if (t != now) std::swap(x.x[t], x.x[now]); if (x[now][i] != 1) for (j = len + 1, t = qpow(x[now][i], P - 2); j >= i; --j) x[now][j] = LL(t) * x[now][j] % P; for (j = i + 1; j <= len; ++j) if (x[j][i]) for (k = len + 1; k >= i; --k) adj(x[j][k] -= LL(x[j][i]) * x[i][k] % P); ++now; } if (now <= len) { for (i = now; i <= len; ++i) if (x[i][len + 1]) return-1; return len - now + 1; } for (i = len; i; --i) for (j = i + 1; j <= len; ++j) adj(x[i][len + 1] -= LL(x[i][j]) * x[j][len + 1] % P); return0; }