#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define PI acos(-1.0)
#define feq(a,b) (fabs(a-b)<1E-4)
double gcd(double a,double b)
{
if(feq(a,0)) return b;
if(feq(b,0)) return a;
return gcd(b,fmod(a,b));
}
inline double bcos( double a, double b, double c )
{
return acos((b*b+c*c-a*a)/(2.0*b*c));
}
inline double len(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
double x1,y1,x2,y2,x3,y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
double a=len(x1,y1,x2,y2);
double b=len(x1,y1,x3,y3);
double c=len(x2,y2,x3,y3);
double p=0.5*(a+b+c);
double s_triangle=sqrt(p*(p-a)*(p-b)*(p-c));
double r=(a*b*c)/(4.0*s_triangle);
double A=bcos(a,r,r);
double B=bcos(b,r,r);
double C=2*PI-A-B;
double T=gcd(A,gcd(B,C));
double s;
s=0.5*r*r*sin(T)*(2*PI/T); //这里wa了好几次,因为把2*PI/T用double类型保存了再算的,倒置关键精度丢失
cout.setf(ios::fixed);
cout << setprecision(8) << s << endl;
return 0;
}
Codeforces 1C Ancient Berland Circus 计算几何
最新推荐文章于 2019-09-26 13:27:20 发布