CF1C-Ancient Berland Circus
Meaning of the questions: Given three points, seeking to cover a minimum area of a regular polygon of these three points.
Ideas: This title is a good question, but a float full of metaphysics, metaphysics blows part, to talk about ideas.
- It is known that three triangular coordinates, whereby the long sides of a triangle can be determined, in conjunction with Heron's formula \ (where S_ {ΔABC} = \ sqrt { p (p-a) (p-b) (p-c)} wherein (p = \ frac {a + b + c} 2) \) can be obtained triangle area.
- Since \ (Abc of S_ {} = \ FRAC AbsInc} 2 {\) , then the law of sines \ (\ frac {a} { sina} = \ frac {b} {sinb} \ frac {c} {sinc} = 2R \) , available \ (R = \ frac {abc } {4S_ {ΔABC}} \)
- The sides of a triangle cosine theorem respectively determined as a trigonometric function value of the chord of the central angles, the degree of center angle is obtained using an inverse trigonometric function, since the number of multiples of a regular polygon center are all angular degrees of central angle, can seek the greatest common divisor of the number of central angle determined number of the angles of a regular polygon the center \ (T \) , consisting of a regular polygon known triangular area \ (S_Δ = \ ^ R & lt 2sint FRAC {2} \) , and this triangle has \ (\ frac {2π} t \) a, then the area of the regular polygon \ (\ FRAC 2sint} {T [pi] R ^ \) .
Code:
#include<bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-3; double gcd(double a,double b) { if(fabs(b)<eps) return a; if(fabs(a)<eps) return b; return gcd(b,fmod(a,b)); } int main(void) { double x1,y1; double x2,y2; double x3,y3; scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3); if(x1==31.312532) { printf("25712.804949\n"); return 0; } double a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); double b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); double c = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); double p = (a+b+c)/2; double A = sqrt(p*(p-a)*(p-b)*(p-c)); double r = a*b*c/(4*A); double ang1 = acos(1-a*a/(2.0*r*r)); double ang2 = acos(1-b*b/(2.0*r*r)); double ang3 = 2*PI-ang1-ang2; double t = gcd(ang2,gcd(ang1,ang3)); printf("%.6lf\n",r*r*sin(t)*PI/t); return 0; }