BZOJ1013 [JSOI2008] spherical space generator sphere

Source: Internet
Author: User

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 point A, B coordinates (a1, a2, ..., an), (B1, B2, ..., BN), then AB distance is defined as: dist = sqrt ((A1-B1) ^2 + (A2-B2) ^2 + ... + (an-bn) ^2)

Exercises

This question ... Do not ignore the line trailing space ... Damn it...

Anyway, since we want to be equal to each other, and have $n$ an unknown, then we should $n$ a equation.

Set the Sphere $o: (x, Y, ..., W) $, $n +1$ points $p_i: (x_i, Y_i, ..., w_i) $,

We choose $dis (O, p_0) = Dis (o, p_i) (0 < i \leq N) $ this $n$ equation, i.e.

$$ (X-X_0) ^2 + (Y-Y_0) ^2 + ... + (w-w_0) ^2 = (x-x_i) ^2 + (y-y_i) ^2 + ... + (w-w_i) ^2$$

Two-item expansion, move items, merge similar terms, get:

$$2 (X_I-X_0) x + 2 (y_i-y_0) y + ... + 2 (w_i-w_0) w = x_i^2-x_0^2 + y_i^2-y_0^2 + ... + w_i^2-w_0^2$$

Gaussian elimination of the element can be.

Attached code:

#include <algorithm> #include <cstdio>const int n = 15;double a[n][n];void gauss (int n) {for (int i = 0; I &l T N    ++i) {int k = i;    for (int j = i + 1; j < n; ++j) if (A[j][i] > a[k][i]) k = j;    for (int j = i; j <= N; ++j) Std::swap (A[i][j], a[k][j]);  for (k = i + 1, k < n; ++k) for (int j = n; j >= i;--j) a[k][j]-= a[i][j] * A[k][i]/a[i][i];    } for (int i = n-1; ~i; i.) {A[I][N]/= a[i][i];  for (int j = i-1; ~j;--j) a[j][n]-= a[i][n] * A[j][i];  }}double P0[n];int Main () {int N;  scanf ("%d", &n);  for (int i = 0; i < n; ++i) scanf ("%lf", &p0[i]);  Double X;    for (int i = 0; i < n; ++i) {a[i][n] =. 0;      for (int j = 0; J < N; ++j) {scanf ("%lf", &x);      A[I][J] = 2 * (X-p0[j]);    A[i][n] + = x * x-p0[j] * P0[J];  }} gauss (n);  printf ("%.3lf", A[0][n]);  for (int i = 1; i < n; ++i) printf ("%.3lf", A[i][n]);  printf ("\ n"); return 0;}

  

BZOJ1013 [JSOI2008] spherical space generator sphere

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.