[[JSOI2008] spherical space generator] (https://www.luogu.org/problemnew/show/P4035)
Gauss de-yuan to make a mess
#include <cstdio>#include<cstring>#include<algorithm>Const intMAXN = -;intN;DoubleLOC[MAXN][MAXN];DoubleST[MAXN],X[MAXN];voidGauss () {intT; for(intI=1; i<=n;++i) {t=i; for(intj=i+1; j<=n;++j)if(Loc[j][i]>loc[t][i]) t=J; if(t!=i) for(intj=i;j<=n+1;++j) Std::swap (Loc[t][j],loc[i][j]); for(intj=i+1; j<=n;++j) {Doubletmp=loc[i][i]/Loc[j][i]; for(intk=i+1; k<=n+1; ++k) loc[j][k]=loc[i][k]-tmp*Loc[j][k]; } } for(inti=n;i>=1;--i) { for(intj=i+1; j<=n;++j) loc[i][n+1]-=x[j]*Loc[i][j]; X[i]=loc[i][n+1]/Loc[i][i]; }}intMain () {scanf ("%d",&N); for(intI=1; i<=n;++i) scanf ("%LF",&St[i]); for(intI=1; i<=n;++i) for(intj=1; j<=n;++j) {Doubletmp; scanf ("%LF",&tmp); LOC[I][J]=2* (st[j]-tmp); Loc[i][n+1]+=st[j]*st[j]-tmp*tmp; } gauss (); for(intI=1; i<=n;++i) printf ("%.3LF", X[i]); return 0;}
[JSOI2008] spherical space generator