Cf -- 1c

Source: Internet
Author: User
1 // accepted 0 kb 60 MS 2 // given the three points on the positive multi deformation, the minimum area of the positive multi-shape 3 // remember the distance between the three points A, B, c; 4 // cosa 5 obtained by cosine theorem // to obtain the center angle of Sina, R 6, radius of the outer circle of the positive polygon, and set the three edges to theta1, theta2, theta3 7 // The center angle of the regular polygon is gcd (theta1, gcd (theta2, theta3) 8 // Where gcd (theta1, theta2) so far, we can find the area of the positive polygon 10 # include <cstdio> 11 # include <cstring> 12 according to the radius R and center angle of the outer circle of the positive polygon. # include <iostream> 13 # include <queue> 14 # include <cmath> 15 # include <algorithm> 16 Using namespace STD; 17 const double Pi = ACOs (-1.0 ); 18/** 19 * This is a documentation comment block20 * @ authr songt21 */22 struct point23 {24 Double X, Y; 25} p [3]; 26 double getdis (point P1, point P2) 27 {28 return SQRT (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y); 29} 30 double gcd (double A, double B) 31 {32 If (FABS (B) <1e-4) return; 33 If (FABS (a) <1e-4) return B; 34 return gcd (B, fmod (A, B); 35} 36 V Oid slove () 37 {38 double A = getdis (P [1], p [2]); 39 Double B = getdis (P [1], p [3]); 40 double C = getdis (P [2], p [3]); 41 double cosa = (B * B + C * C-A *) /(2 * B * C); 42 double Sina = SQRT (1-cosa * COSA); 43 Double R = A/(2 * Sina ); 44 // printf ("r = % lf \ n", R); 45 double thetaa = 2 * asin (A/(2 * r )); 46 Double thetab = 2 * asin (B/2/R); 47 // double thetac = 2 * asin (C/2/R ); 48 double thetac = 2 * pi-thetaa-thetab; 49 // printf ("% lf \ n", thetaa + thetab + thetac); 50 Double Theta = gcd (thetaa, gcd (thetab, thetac); 51 // printf ("Theta = % lf \ n", theta ); 52 // printf ("Pi = % lf \ n", Pi); 53 double S = 2 * PI/Theta * r/2 * sin (theta ); 54 printf ("%. 6lf \ n ", S); 55} 56 int main () 57 {58 While (scanf (" % lf ", & P [1]. x, & P [1]. y, & P [2]. x, & P [2]. y, & P [3]. x, & P [3]. Y )! = EOF) 59 slove (); 60 return 0; 61}
View code

 

Cf -- 1c

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.