I (do not calculate geometry): This is not the computational geometry AH (desperate face).
Llj big Guy (glanced at): This is Gaussian elimination yuan Ah.
Gaussian elimination element.
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>#include<queue>#include<vector>typedefLong LongLL;using namespacestd;Const intmaxn= the;intN;DoubleX[MAXN][MAXN],F[MAXN][MAXN];voidsolve () { for(intI=1; i<=n;i++) { intnow=i; for(intj=i;j<=n;j++) if(F[j][i]>f[now][i]) now=J; if(now!=i) { for(intj=i;j<=n+1; j + +) Swap (f[now][j],f[i][j]); now=i; } if(!f[i][i])return; for(intj=i+1; j<=n+1; j + +) f[i][j]/=F[i][i]; F[i][i]=1; for(intj=i+1; j<=n;j++) { for(intk=i+1; k<=n+1; k++) F[j][k]-=f[i][k]*F[j][i]; F[j][i]=0; } } for(inti=n;i>=1; i--) for(intj=i+1; j<=n;j++) F[i][n+1]-=f[i][j]*f[j][n+1];}intMain () {//freopen (". In", "R", stdin); //freopen (". Out", "w", stdout);scanf"%d",&N); for(intI=1; i<=n+1; i++) for(intj=1; j<=n;j++) scanf ("%LF",&X[i][j]); for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) {F[i][j]=2* (x[i][j]-x[i+1][j]); F[i][n+1]+= (x[i][j]*x[i][j]-x[i+1][j]*x[i+1][j]); } solve (); for(intI=1; i<n;i++) printf ("%.3LF", f[i][n+1]); printf ("%.3lf\n", f[n][n+1]); return 0;}
View Code
Bzoj 1013[jsoi2008] Spherical space generator sphere