"Gaussian elimination Element" "Jsoi 2008" "Bzoj 1013" spherical space generator sphere

Source: Internet
Author: User

1013: [JSOI2008] spherical space generator sphere
Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3211  Solved: 1685

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 only know the coordinates of the n+1 points on the sphere, and 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. 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 accurate to 6 digits after the decimal point, and its 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 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

20.0 0.0-1.0 1.01.0 0.0

Sample Output

0.500 1.500

HINT

Data size:

对于40%的数据,1<=n<=3对于100%的数据,1<=n<=10

Tips:

给出两个定义:1、 球心:到球面上任意一点距离都相等的点。2、 距离:设两个n为空间上的点A, B的坐标为(a1, a2, …, an), (b1, b2, …, bn),则AB的距离定义为:dist = sqrt( (a1-b1)^2 + (a2-b2)^2 + … + (an-bn)^2 )

Exercises

Gaussian elimination of the naked problem.
According to the hint can be used as a point of entry, because the n+1 points, so you can use a point as a datum point, and other n points to form n equations.

Code:

#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <algorithm>using namespace STD;intNDoublea[ -][ -]={0},b[ -]={0},c[ -][ -]={0};intMain () {scanf("%d", &n); for(intI=1; i<=n+1; i++) for(intj=1; j<=n; J + +)scanf("%LF", &c[i][j]);Doublex=0; for(intI=1; i<=n; i++) { for(intj=1; j<=n; J + +) {a[i][j]=2* (c[i][j]-c[i+1][J]); x+= (C[i][j]*c[i][j])-(c[i+1][j]*c[i+1][J]); } a[i][n+1]=x; x=0; } for(intI=1; i<=n; i++) {if(a[i][i]==0){ for(intj=i+1; j<=n; J + +) {if(a[j][i]!=0){ for(intk=1; k<=n+1; k++) Swap (a[i][k],a[j][k]); Break; }            }        } for(intj=i+1; j<=n; J + +) {X=a[j][i]/a[i][i]; for(intk=1; k<=n+1;        k++) a[j][k]-=a[i][k]*x; }    } for(intI=n; i>=1; i--) {b[i]=a[i][n+1]/a[i][i]; for(intj=i-1; j>=1; j--) {a[j][n+1]-=a[j][i]*b[i]; a[j][i]=0; }    } for(intI=1; i<n; i++)printf("%.3f", B[i]);printf("%.3f\n", B[n]);return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Gaussian elimination" "Jsoi 2008" "Bzoj 1013" 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.