1013: [JSOI2008] spherical space generator sphere

Source: Internet
Author: User

1013: [JSOI2008] spherical space generator sphere time limit:1 Sec Memory limit:162 MB
submit:6517 solved:3381
[Submit] [Status] [Discuss] 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.


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.


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)


There is a ball in an n-dimensional space, and then the center of the circle is calculated. The n+1 points on the ball are given.

This n+1 point is equal to the distance of the sphere. Set the Circle Center $ (a_1,a_2...a_n) $, then for each ball on the point $ (x_1,x_2...x_n) $, there are

$ (x_1-a_1) ^2+ (x_2-a_2) ^2+...+ (x_n-a_n) ^2=r^2$

22 Merge, then get a linear equation, using Gaussian elimination element.

1#include <cstdio>2#include <cmath>3#include <algorithm>4 5 using namespacestd;6 Const intN = the;7 DoubleA[n][n],c[n];8 intN;9 Ten voidGauss () { One      for(intk=1; k<=n; ++k) { A         //Select line R and line I interchange -         intR =K; -          for(inti=k+1; i<=n; ++i) the             if(Fabs (a[i][k]) > Fabs (a[r][k])) R =i; -         if(r! = k) for(intj=1; j<=n+1; ++j) Swap (A[r][j],a[k][j]); -         //eliminate Yuan -          for(inti=k+1; i<=n; ++i) { +             Doublet = a[i][k]/A[k][k]; -              for(intJ=k; j<=n+1; ++J) a[i][j]-= t*A[k][j]; +         } A     } at     //Back to Generation -      for(intI=n; i>=1; --i) { -          for(intj=i+1; j<=n; ++j) -a[i][n+1]-= a[j][n+1]*A[i][j]; -a[i][n+1] /=A[i][i]; -     } in } - intMain () { to     Doublex; +scanf"%d",&n); -      for(intI=1; i<=n; ++i) thescanf"%LF",&c[i]); *      for(intI=1; i<=n; ++i) $          for(intj=1; j<=n; ++j) {Panax Notoginsengscanf"%LF",&x); -A[I][J] = (x*2-c[j]*2); thea[i][n+1] + = (x*x-c[j]*c[j]); +         } A Gauss (); the      for(intI=1; i<n; ++i) +printf"%.3LF", a[i][n+1]); -printf"%.3LF", a[n][n+1]); $     return 0; $}

1013: [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.