Codeforces Round #1C Ancient Berland Circus

#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>

using namespace std;

const double PI = acos(-1.0);
const double eps = 0.01; 

struct coordinate {
	double x, y;
};

bool feq (double a, double b) {  
	return fabs(a-b) < eps;  
}  

double fgcd(double a, double b) {  
	if (feq(a, 0)) return b;  
	if (feq(b, 0)) return a;  
	return fgcd(b, fmod(a, b));  
}  

double CALL (double x1, double y1, double x2, double y2)
{
	return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
int main()
{
    coordinate c;
	vector<coordinate> v;
	double L[3];
	double Ang[3];
	double R, S, P;
	
	for (int i = 0; i < 3; ++i) {
		cin >> c.x >> c.y;
		v.push_back(c);
	}

	for (int i = 0; i < 3; ++i) {
		L[i] = CALL(v[i].x, v[i].y, v[(i + 1) % 3].x, v[(i + 1) % 3].y);
	}

	P = (L[0] + L[1] + L[2]) / 2;
	S = sqrt(P * (P - L[0]) * (P - L[1]) * (P - L[2]));
	R = L[0] * L[1] * L[2] / (4 * S);

	for (int i = 0; i < 3; ++i) {
		Ang[i] = acos(1 - L[i] * L[i] / (2 * R * R));
	}

	Ang[2] = 2 * PI - Ang[0] - Ang[1];

	double Angel = 0.0;
	for (int i = 0; i < 3; ++i) {
		Angel = fgcd(Angel, Ang[i]);
	}
	
	cout << setprecision(6) << setiosflags(ios:: fixed) << R * R * sin(Angel) * PI / Angel << endl;
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值