Time limit:1 Sec Memory limit:162 MB
submit:5233 solved:2736 Description
There is a spherical space generator capable of producing a hard sphere in n-dimensional space. Now that you're trapped in this n-dimensional sphere, you only know the ball.
The coordinates of the n+1 points on the surface, 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 (1<=n=10). 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 exactly the decimal point.
6 bits, and the 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 accurate to the decimal point
After 3 bits. Data is guaranteed to be solvable. Your answer must be the same as the standard output in order to score.
Sample Input2
0.0 0.0
-1.0 1.0
1.0 0.0Sample Output0.500 1.500HINT
Tip: Give two definitions: 1, Sphere: points that are equal to any point on the sphere. 2, Distance: Set two n for space on the point A, B
Coordinates for (A1, A2, ..., an), (B1, B2, ..., bn), the distance of AB is defined as: dist = sqrt ((A1-B1) ^2 + (A2-B2) ^2 +
... + (AN-BN) ^2)
Source
Gaussian elimination of mathematical problems
According to the test instructions list of n+1 equations, using the first n+1 to eliminate the first n of a unary, to obtain a solvable N-element equations, Gaussian elimination of the solution can be.
However, the confusion is that Gaussian elimination in the exchange of a two-line equation of operation, it is logically affect the order of the answer, but can still
Well, "exactly the same as the standard output."
1 /*by Silvern*/2#include <iostream>3#include <algorithm>4#include <cstring>5#include <cstdio>6#include <cmath>7 using namespacestd;8 intN;9 Doublef[ -][ -];Ten voidGauss () { One inti,j,k; A for(i=0; i<n;i++){ - intp=i; - for(j=i+1; j<n;j++){ the if(F[j][i]>f[p][i]) p=J; - } - if(p!=i) for(j=i;j<=n;j++) Swap (f[i][j],f[p][j]); - for(j=i+1; j<n;j++){ + Doublex=f[j][i]/F[i][i]; - for(k=i;k<=n;k++){ +f[j][k]-=f[i][k]*x; A } at } - } - for(i=n-1; i>=0; i--){ - for(intj=i+1; j<n;j++) f[i][n]-=f[j][n]*F[i][j]; -F[i][n]/=F[i][i]; - } inprintf"%.3f", f[0][n]); - for(i=1; i<n;i++){ toprintf"%.3f", F[i][n]); + } - return; the } * intMain () { $ inti,j;Panax Notoginsengscanf"%d",&n); - for(i=0; i<n;i++) scanf ("%LF",&f[n][i]); the for(i=0; i<n;i++){ + for(j=0; j<n;j++){ Ascanf"%LF",&f[i][j]); thef[i][n]+=f[i][j]*f[i][j]-f[n][j]*F[n][j]; +f[i][j]=2* (f[i][j]-f[n][j]); - } $ } $ Gauss (); - return 0; -}
Bzoj1013 [JSOI2008] spherical space generator sphere