"Bzoj" "1013" "JSOI2008" spherical space generator sphere

Source: Internet
Author: User

Gaussian elimination element

Gaussian elimination template problem

To tell you the truth, how did that equation Group (augmented matrix) come out? I haven't quite figured it out yet ...

1 /**************************************************************2 problem:10133 User:tunix4 language:c++5 result:accepted6 time:0 Ms7 memory:1272 KB8 ****************************************************************/9  Ten //Bzoj 1013 One#include <cmath> A#include <cstdio> -#include <cstring> -#include <cstdlib> the#include <iostream> -#include <algorithm> - #defineRep (i,n) for (int i=0;i<n;++i) - #defineF (i,j,n) for (int i=j;i<=n;++i) + #defineD (i,j,n) for (int i=j;i>=n;--i) - using namespacestd; + voidReadint&v) { Av=0;intsign=1;CharCh=GetChar (); at      while(ch<'0'|| Ch>'9'){if(ch=='-') sign=-1; Ch=GetChar ();} -      while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} -v*=Sign ; - } - /******************tamplate*********************/ - Const intn= One; intypedefDoubleMatrix[n][n]; - voidGauss (Matrix A,intN) { to     intI,j,k,r; +      for(i=0; i<n;++i) { -         //Select Line R and Exchange with line I theR=i; *          for(j=i+1; j<n;++j) $             if(Fabs (A[j][i]) > Fabs (a[r][i]) r=J;Panax Notoginseng         if(r!=i) for(j=0; j<=n;++j) Swap (A[r][j],a[i][j]); -           the         //The elimination of the I+1~n line with section +          for(k=i+1; k<n;++k) { A             DoubleF=a[k][i]/a[i][i];//in order to make a[k][i]=0, the multiples of line I multiply the              for(J=I;J&LT;=N;++J) a[k][j]-=f*A[i][j]; +         } -     } $     //The process of generation back $      for(i=n-1; i>=0; i--){ -          for(j=i+1; j<n;j++) -a[i][n]-=a[j][n]*A[i][j]; theA[i][n]/=A[i][i]; -     }Wuyi } the Matrix F; - intN; Wu intMain () { -scanf"%d",&n); AboutF (I,0, N) { $ Rep (j,n) { -scanf"%LF",&f[i][j]); -f[i][n]-=f[i][j]*F[i][j]; -f[i][j]*=-2.0; A             if(i) f[i-1][j]-=F[i][j]; +         } the         if(i) f[i-1][n]-=F[i][n]; -     } $ Gauss (f,n); theprintf"%.3f", f[0][n]); the      for(intI=1; i<n;++i) printf ("%.3f", F[i][n]); the     return 0; the}
View Code

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