显示代码纯文本
//Asm_Def
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
template<typename T>inline void getd(T &x){
char c = getchar();
bool minus = 0;
while(!isdigit(c) && c != '-')c = getchar();
if(c == '-')minus = 1, c = getchar();
x = c - '0';
while(isdigit(c = getchar()))x = x * 10 + c - '0';
if(minus)x = -x;
}
/*======================================================*/
const double eps = 1e-12;
double *Eq[11], Ans[11];
int N;
inline void init(){
double a, P[11][12];
getd(N);int i, j;
for(j = 0;j < N;++j)scanf("%lf", *P + j);
for(i = 1;i <= N;++i){
for(j = 0;j < N;++j)
scanf("%lf", P[i] + j);
P[i-1][N] = 0;
for(j = 0;j < N;++j){
a = P[i-1][j] + P[i][j];
P[i-1][j] = P[i][j] - P[i-1][j];
P[i-1][N] += a * P[i-1][j] / 2.0;
}
Eq[i-1] = P[i-1];
}
}
inline void solve(){
int i, j, k;
double frac;
for(i = 0;i < N;++i){
for(j = i+1;j < N;++j)
if(fabs(Eq[i][i]) < fabs(Eq[j][i]))swap(Eq[i], Eq[j]);
if(fabs(Eq[i][i]) < eps){
cout << "No Answer" << endl;
exit(1);
}
for(j = i+1;j < N;++j){
if(fabs(frac = Eq[j][i] / Eq[i][i]) < eps)continue;
Eq[j][i] = 0;
for(k = i+1;k <= N;++k)
Eq[j][k] -= frac * Eq[i][k];
}
}
for(i = N-1;i >= 0;--i){
Ans[i] = Eq[i][N] / Eq[i][i];
for(j = 0;j < i;++j)
Eq[j][N] -= Eq[j][i] * Ans[i];
}
for(i = 0;i < N;++i)
printf("%.3lf ", Ans[i]);
}
int main(){
#if defined DEBUG
//freopen("test", "r", stdin);
#else
freopen("bzoj_1013.in", "r", stdin);
freopen("bzoj_1013.out", "w", stdout);
#endif
init();
solve();
#if defined DEBUG
//cout << endl << (double)clock()/CLOCKS_PER_SEC << endl;
#endif
return 0;
}