1 void solve(){ 2 rep(i,1,n+1){ 3 int t=i; 4 rep(j,i+1,n+1) if(fabs(a[j][i])>fabs(a[t][i])) t=j; 5 if(t!=i) rep(j,1,n+2) swap(a[i][j],a[t][j]); 6 rep(k,i+1,n+1){ 7 double p=a[k][i]/a[i][i]; 8 rep(j,i,n+2) a[k][j]-=p*a[i][j]; 9 } 10 } 11 for(int i=n+1;i;i--){ 12 rep(j,i+1,n+1) a[i][n+1]-=a[j][n+1]*a[i][j]; 13 a[i][n+1]/=a[i][i]; 14 } 15 rep(i,1,n+1){ 16 printf("%.3lf",a[i][n+1]); 17 if(i!=n) putchar(' '); 18 } 19 }