Seek the god of ~>_< to forgive
Based on the relationship of equal radii, the n+1 two-time equations are established.
Then each and the previous subtract two entries, get n a linear equation.
#include <cstdio> #include <cmath> #include <algorithm> #include <cstring>using namespace std;# Define N 11int n;double b[n][n+1],a[n][n+1],x[n],b[n],pl[n+1][n];d ouble sqr (double x) {return x*x;} void Guass_jordan () {memcpy (b,a,sizeof (A)), for (int i=1;i<=n;++i) b[i][n+1]=b[i];for (int i=1;i<=n;++i)//enumeration: The first unknown is being eliminated, and then the I equation is discarded, matrix row, column-1 {int pivot=i; for (int j=i+1;j<=n;++j)//Enumeration J: The equation of the highest absolute value of the coefficients of the unknown being processed is swapped to the line I if (Fabs (B[j][i]) >fabs (b[pivot][i)) pivot=j; Swap (B[i],b[pivot]); if (Fabs (B[i][i]) <eps)//If all (maximum) of the unknown coefficient is 0, indicating less an unknown number, there is an infinity solution for (int j=i+1;j<=n+1;++j) b[i][j]/=b[i][i]; for (int j=1;j<=n;++j) if (i!=j)//Enumerates all equations, removes the first unknown for (int k=i+1;k<=n+1;++k) from the first J equation, and subtracts the number of the first k unknowns in the J B[J][K]-=B[J][I]*B[I][K]; }for (int i=1;i<=n;++i) x[i]=b[i][n+1];} int main () {scanf ("%d", &n), for (int. i=1;i<=n+1;++i) {for (int j=1;j<=n;++j) scanf ("%lf", &pl[i][j]); if (i>1) for (int j=1;j<=n;++j) {B[I-1]+=SQR (pl[i-1][J])-sqr (Pl[i][j]); A[I-1][J]=2.0*PL[I-1][J]-2.0*PL[I][J]; }}guass_jordan (); for (int i=1;i<n;++i) printf ("%.3f", X[i]);p rintf ("%.3f\n", X[n]); return 0;}
Gaussian elimination bzoj1013 [JSOI2008] spherical space generator sphere