Codeforces Round #1 C subject ent Berland Circus (Computational ry ),
The idea of this question can be divided into the following four steps:
1: Calculate the radius of the external shard
2: ask for three round angles.
3: calculate the maximum common approx.
4: The maximum common divisor is the biggest inner angle of the positive polygon. Just calculate the area.
But every step won't ask .... Sad... When I think of step 2, I even think that I should use other methods .. .. The ry is too scum.
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(x-y)<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;}