Bzoj 1013 & Gaussian elimination element

Source: Internet
Author: User

Test instructions

Tells you a k+1 point on a sphere of k-dimensional spheres asking the spherical coordinates.

Sol

At first glance I thought it was a k-dimensional answer and judged the distance ... What a jerk. You look at the messy topics and then forget the most useful basic calculations ...

We can see that, assuming the center O, according to the formula that he tells us we can get an equation of any two points and a center point, the equation has K unknowns, then we randomly construct K equations and then run a Gaussian elimination.

The mechanical industry's line is still quite clear and understandable ... Each time you enumerate to one of the main rows, the following each one is eliminated ... Well... More intuitive ...

Because the last line of change also PE ... A little tipsy = =

CODE:

  

/*==========================================================================# last modified:2016-03-03 15:29# filename:1013.cpp# Description: ==========================================================================*/# Define me Acrossthesky #include <cstdio> #include <cmath> #include <ctime> #include <string> #inc (in)  Lude <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> #include <map> #include <stack> #include <queue> #include <vector> #define LOWBIT (x) (x) & (-X ) #define for (I,A,B) for ((i) = (a);(i) <= (b);(i) + +) #define FORP (I,A,B) for (int i= (a); i<= (b); i++) #define FORM (i,a,b ) for (int i= (a); i>= (b); i--) #define LS (A, a) (((a) + (b)) << 1) #define RS (A, B) (((a) + (c)) >> 1) #define GETLC (a) ch[(a)][0] #define GETRC (a) ch[(a)][1] #define Delta 1e-6#define MAXN 100000 #define MAXM 100000 #define PI 3.14159265 35898 #define _E 2.718281828459 #define INF 10700000The using namespace Std; typedef long Long LL;  typedef unsigned long long ull;     Template<class t> inline void read (t& num) {bool start=false,neg=false;     char c;     num=0;         while ((C=getchar ())!=eof) {if (c== '-') start=neg=true;             else if (c>= ' 0 ' && c<= ' 9 ') {start=true;         num=num*10+c-' 0 ';     } else if (start) break; } if (neg) num=-num; }/*==================split line==================*/Double m[20][20],p[20][20],ans[20];int n;int judge (Double X, Double T) {if (Fabs (x-t) <=delta) return 0;else if (x>t) return 1;return-1;} void Gauss_elimination () {double t=1.0; Forp (i,1,n) {if (Judge (m[i][i],0)!=0) T=m[i][i];else continue; Forp (j,i,n+1) m[i][j]/=t; Forp (j,i+1,n) {t=m[j][i]; Forp (k,i,n+1) m[j][k]-=t*m[i][k];} Check ();} FORM (i,n,1) {Forp (j,i+1,n) m[i][n+1]-=m[i][j]*ans[j];ans[i]=m[i][n+1];}} int main () {read (n); Forp (i,1,n+1) Forp (j,1,n) {scanf ("%lf", &p[i][j]);} Forp (i,2,n+1) {Forp (j,1,n) {m[i-1][j]=p[i][j]-p[1][j]; m[i-1][n+1]+= ((P[i][j]*p[i][j]-p[1][j]*p[1][j])/2.0);}} Gauss_elimination (); Forp (i,1,n-1) printf ("%.3lf", Ans[i]); printf ("%.3lf", Ans[n]);}

Bzoj 1013 & Gaussian elimination element

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.