[Bzoj 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: 5995   [Submit][status][discuss] 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 know only the coordinates of the n+1 points on the
plane of the ball, and 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 of

Input

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 6 digits from the decimal point
, and its absolute value is no more than 20000.

Output

Has only one row, giving the n-dimensional coordinates (n real numbers) of the globe, in turn, separated by a space between two real numbers. 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.

Sample Input 2
0.0 0.0
-1.0 1.0
1.0 0.0 Sample Output 0.500 1.500 HINT

 

Hint: give two definitions: 1, Sphere: points that are equal to any point on the sphere. 2, Distance: Set two n for the space point A, B

coordinates (a1, a2, ..., an), (B1, B2, ..., bn), the distance of AB is defined as: dist = sqrt ((A1-B1) ^2 + (A2-B2) ^2 + 
br> ... + (an-bn) ^2)

Before the league pits found not how to play Gaussian elimination and then hit a Owo

Exercises

Generates $n $ equations based on the given $n +1$ points. After pushing the formula, we found that the two items were eliminated, so there was only one item left, and the corresponding coefficients were calculated directly to run high.

However, the topic of bereavement card output ... PE a pitch ...

Reference Code

GitHub

1#include <cmath>2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <iostream>6#include <algorithm>7 8 Const intmaxn= -;9 Ten intN; One DoubleANS[MAXN]; A DoubleA[MAXN][MAXN]; - DoubleM[MAXN][MAXN]; -  the voidInitialize (); - voidgaussianelimination (); -  - intMain () { + Initialize (); - gaussianelimination (); +printf"%.3LF", ans[0]); A      for(intI=1; i<n;i++) atprintf"%.3LF", Ans[i]); -Putchar ('\ n'); -     return 0; - } -  - voidInitialize () { inscanf"%d",&n); -      for(intI=0; i<=n;i++){ to          for(intj=0; j<n;j++){ +scanf"%LF", a[i]+j); -         } the     } *      for(intI=0; i<n;i++){ $          for(intj=0; j<n;j++){Panax Notoginsengm[i][j]=2* (a[i+1][j]-a[i][j]); -m[i][n]+=a[i+1][j]*a[i+1][j]-a[i][j]*A[i][j]; the         } +     } A } the  + voidgaussianelimination () { -      for(intI=0; i<n;i++){ $          for(intj=i+1; j<n;j++){ $             Doubledelta=m[j][i]/M[i][i]; -              for(intk=0; k<=n;k++){ -m[j][k]-=delta*M[i][k]; the             } -m[j][i]=0;Wuyi         } the     } -      for(inti=n-1; i>=0; i--){ Wu         DoubleL=0; -          for(intj=i+1; j<n;j++){ Aboutl+=ans[j]*M[i][j]; $         } -ans[i]= (m[i][n]-l)/M[i][i]; -     } -}
Backup

[Bzoj 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.