The idea of the problem is very good to think, divided into the following 4 steps:
1: Seek the radius of the circumscribed garden
2: Ask for three central angle
3: Find the greatest common divisor of three center angle
4: Greatest Common divisor is the largest regular polygon internal angle, to find the area can be.
But every step does not beg ah .... Sad ... When I think of the 3rd step, I even feel that I should ask for it in another way. To change the method. The geometry is too slag.
The code is as follows:
#include <iostream> #include <string.h> #include <math.h> #include <queue> #include < algorithm> #include <stdlib.h> #include <map> #include <set> #include <stdio.h>using namespace std; #define LL __int64#define Pi ACOs ( -1.0) const int Mod=100000000;const int Inf=0x3f3f3f3f;const double eqs=0. 01;struct point{double x, y;} P[4];bool DMP (double x, double y) {return fabs (XY) <eqs;} Double FGCD (double x, double y) {if (DMP (x,0)) return y; if (DMP (y,0)) return x; Return FGCD (Y,fmod (x, y));} Double Dist (Point F1, point F2) {return sqrt ((f1.x-f2.x) * (f1.x-f2.x) + (F1.Y-F2.Y) * (F1.Y-F2.Y));} int main () {double S, R, Ang[4], D[4], pp, angle; int i; for (i=0;i<3;i++) {scanf ("%lf%lf", &p[i].x,&p[i].y); } for (i=0;i<3;i++) {d[i]=dist (p[i],p[(i+1)%3]); } pp= (D[0]+d[1]+d[2])/2.0; S=sqrt (pp* (pp-d[0]) * (pp-d[1]) * (pp-d[2])); r=d[0]*d[1]*d[2]/(4*s); Ang[0]=acos (1-d[0]*d[0]/(2*r*r)); Ang[1]=acos(1-d[1]*d[1]/(2*r*r)); ANG[2]=2*PI-ANG[0]-ANG[1]; ANGLE=FGCD (ang[0],ang[1]); ANGLE=FGCD (angle,ang[2]); printf ("%.6f\n", R*r*pi*sin (angle)/angle); return 0;}
Codeforces Round #1 C Ancient Berland Circus (computational geometry)