Description
There is a spherical space generator capable of producing a hard sphere in n-dimensional space. Now that you are trapped in this n-dimensional sphere, you only know the coordinates of the n+1 points on the sphere, and you need to determine the spherical coordinates of the n-dimensional sphere as quickly as you can to destroy the sphere space generator.
Input
The first line is an integer, N. The next n+1 line, each row has n real numbers, representing the n-dimensional coordinates of a point on the sphere. Each real number is accurate to 6 digits after the decimal point, and its absolute value is no more than 20000.
Output
With only one row, the n-dimensional coordinates (n real numbers) of the globe are given in turn, and two real numbers are separated by a space. Each real number is exactly 3 digits after the decimal point. Data is guaranteed to be solvable. Your answer must be the same as the standard output in order to score.
Template title: At first I also heard the card precision and so on. What's the biggest common multiple or something, and what's the biggest line? Not at all, Qaq. Then I insisted on playing naked. Thought: Let's consider two dimensions first. (x-x1) y-y1 2= (x-x2) (Y-Y2) 2 let's simplify. First X2 and Y2 can be offset. And then it's loved to get it. And then it was. becomes 2X (x2-x1) +2y (y2-y1) after =x22-x12+y22-y12 can expand into n-dimensional spicy. After that is loved Gauss to eliminate yuan spicy. I used to turn the matrix into a triangle. A hand. PE? What GUI error? I heard the last to add \ n? All right, hand it over again. WA? Well, printf is out there. 3lf. Go on. RE? Well, I'm not stingy with space. Go on. You loved the A? Really god, Card precision cards format--
1#include <cstdio>2#include <cstring>3#include <cmath>4#include <algorithm>5 6 using namespacestd;7 8 Doublef[ $][201],ga[ $][ $],ans[ $];9 Ten intN; One A voidSolve () - { - for(inti=n;i>=1; i--) the { -ans[i]=ga[i][n+1]; - for(intj=i+1; j<=n;j++) -ans[i]-=ans[j]*Ga[i][j]; +Ans[i]/=Ga[i][i]; - } + } A at voidGuass () - { - for(intI=2; i<=n;i++)//number of enumeration processing - for(intj=i;j<=n;j++)//the first few of the equation - { - Doublegg=ga[j][i-1]/ga[i-1][i-1]; in for(intk=i;k<=n+1; k++)//several unknown items of the equation -ga[j][k]=gg*ga[i-1][k]-Ga[j][k]; to } + Solve (); - } the * intMain () $ {Panax Notoginsengscanf"%d",&n); - for(intI=1; i<=n+1; i++) the for(intj=1; j<=n;j++) +scanf"%LF",&f[i][j]); A for(intI=1; i<=n;i++) the for(intj=1; j<=n;j++) +Ga[i][j]= (f[i+1][J]-F[I][J]) *2, ga[i][n+1]+=f[i+1][j]*f[i+1][j]-f[i][j]*F[i][j]; - Guass (); $ for(intI=1; i<n;i++) $printf"%.3LF", Ans[i]); -printf"%.3lf\n", Ans[n]); - return 0; the}
View Code
About Gauss elimination, My Computer room God YSP wrote an easy-to-understand blog:http://www.cnblogs.com/robert-yuan/p/4621481.html
"Gaussian elimination" Bzoj 1013: [JSOI2008] spherical space generator sphere