#P4035. Determining the Center of an n-dimensional Sphere
Determining the Center of an n-dimensional Sphere
Determining the Center of an n-dimensional Sphere
A spherical generator creates a hard sphere in an \(n\)-dimensional space. You find yourself trapped in this sphere and the only clues available to you are the coordinates of \(n+1\) points on its surface. Your mission is to determine as quickly as possible the coordinates of the sphere's center so that you can disable the spherical generator.
The mathematical description is as follows. If the center of the sphere is \(C=(c_1, c_2, \dots, c_n)\) and a point on the surface is \(P=(p_1, p_2, \dots, p_n)\), then the radius \(R\) satisfies:
[ \sum_{i=1}^{n}(p_i-c_i)^2 = R^2 ]
Given \(n+1\) points \(P_0, P_1, \dots, P_n\) on the surface, the center \(C\) can be found by setting up \(n\) equations obtained by subtracting the equation for \(P_0\) from each of the equations for \(P_i\) (\(i \ge 1\)). The resulting system of linear equations can be solved to determine \(C\).
inputFormat
The first line of input contains a single integer \(n\) (\(1 \leq n \leq 10\)), representing the dimension of the space. The following \(n+1\) lines each contain \(n\) real numbers separated by spaces, representing the coordinates of a point on the sphere's surface.
outputFormat
Output \(n\) real numbers representing the coordinates of the sphere's center. Each coordinate should be printed with at least 6 decimal places of precision.
sample
1
-1
5
2.000000