BZOJ1013 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 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.

Idea: The equation can be listed, because the distance from each point on the ball to the sphere is equal, so two-phase subtraction can just list n equations, then Gaussian elimination of the element.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <string>6#include <algorithm>7 Doublea[ -][ -],f[ -],t,eps=1e-8;8 intN;9 DoubleSqrDoublex) {Ten     returnx*x; One } A voidGauss () { -     intnow=1, to;DoubleT; -      for(intI=1; i<=n;i++){ the          for(to=now;to<=n;to++)if(Fabs (A[to][i]) >eps) Break; -         if(to>n)Continue; -         if(to!=Now ) -          for(intj=1; j<=n+1; j + +) + Std::swap (A[to][j],a[now][j]); -t=A[now][i]; +          for(intj=1; j<=n+1; j + +) a[now][j]/=T; A          for(intj=1; j<=n;j++) at          if(j!=Now ) { -t=A[j][i]; -               for(intk=1; k<=n+1; k++) -a[j][k]-=t*A[now][k]; -          }  -now++;  in     } - } to intMain () { +scanf"%d",&n); -      for(intI=1; i<=n;i++) thescanf"%LF",&f[i]); *      for(intI=1; i<=n;i++){ $          for(intj=1; j<=n;j++){Panax Notoginsengscanf"%LF",&t); -a[i][j]=2* (tf[j]); thea[i][n+1]+=SQR (t)-Sqr (F[j]); +         } A     }  the Gauss (); +      for(intI=1; i<=n-1; i++) -printf"%.3f", a[i][n+1]); $printf"%.3f\n", a[n][n+1]);  $}

BZOJ1013 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.