Bzoj 1013 JSOI2008 Spherical space Generator sphere Gaussian elimination element

Source: Internet
Author: User

Topic: Given n-dimensional space under the n+1 point, the N-point of the spherical sphere

I've been trying for a long time. Simulated annealing 0.0 still not AC 0.0

Today, digging the dung wall to learn the Gaussian elimination yuan ...

We set the sphere to X (x1,x2,..., xn)

Suppose there are two points a (a1,a2,..., an) and B (B1,b2,..., bn)

Then we can get two equations.

(X1-A1) ^2+ (X2-A2) ^2+...+ (Xn-an) ^2=r^2

(X1-B1) ^2+ (X2-B2) ^2+...+ (xn-bn) ^2=r^2

These equations are all two times and cannot be applied to Gaussian elimination

But we can do some processing. Subtract the above two equations to get a

(A1-B1) x1+ (A2-B2) x2+...+ (an-bn) xn=[(a1^2-b1^2) + (a2^2-b2^2) +...+ (an^2-bn^2)]/2

R is eliminated, n equations, n unknowns can be applied to Gaussian elimination template

has been tangled in the simulated annealing why not cut off 0.0

#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include < Algorithm> #define M 20using namespace Std;int n;double pos[m],a[m][m],ans[m];int main () {int i,j,k;cin>>n;for ( i=1;i<=n;i++) scanf ("%lf", &pos[i]), for (i=1;i<=n;i++) {double temp[m];for (j=1;j<=n;j++) {scanf ("%lf", &TEMP[J]); a[i][j]=pos[j]-temp[j];a[i][n+1]+=pos[j]*pos[j]-temp[j]*temp[j];} a[i][n+1]/=2;} for (i=1;i<=n;i++) {k=0;for (j=i;j<=n;j++) if (Fabs (A[j][i]) >fabs (A[k][i])) k=j;for (j=1;j<=n+1;j++) Swap ( A[I][J],A[K][J]); for (j=i+1;j<=n;j++) {double temp=-a[j][i]/a[i][i];for (k=i;k<=n+1;k++) a[j][k]+=a[i][k]* temp;}} for (i=n;i;i--) {for (j=n;j>i;j--) a[i][n+1]-=a[i][j]*ans[j];ans[i]=a[i][n+1]/a[i][i];} for (i=1;i<=n;i++) printf ("%.3lf%c", ans[i],i==n? ' \ n ': ');}


Bzoj 1013 JSOI2008 Spherical space Generator sphere 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.