1. 程式人生 > >CF1C Ancient Berland Circus 計算幾何

CF1C Ancient Berland Circus 計算幾何

題意翻譯

現在所有的馬戲團在 Berland 都有一個直徑13米的圓形競技場, 但在過去的事情是不同的。

在古代 Berland 競技場的馬戲團被塑造成一個規則 (等角) 多邊形, 角色的大小和角度可能因馬戲團而異。競技場的每個角落都有一根特別的柱子, 柱子之間的繩子標記著競技場的邊緣。

最近, 來自 Berland 的科學家發現了古代馬戲團競技場的遺蹟。他們發現只有三根柱子, 其他的被毀壞了

你得到了這三根柱子的座標。請找出競技場中最小的區域。

輸入三行,每行包含兩個數字,表示柱子的座標,座標的絕對值不超過1000,小數點後不超過6位。

輸出古代競技場的可能的最小區域面積,精確到小數點後至少6位,保證在最佳答案中多邊形角的數目不大於100。

題目描述

Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.

In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.

Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.

You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.

輸入輸出格式

輸入格式:

The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.

輸出格式:

Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.

輸入輸出樣例

輸入樣例#1: 複製

0.000000 0.000000
1.000000 1.000000
0.000000 1.000000

輸出樣例#1: 複製

1.00000000
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 100005
#define inf 0x3f3f3f3f
#define INF 999999999999999
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 20100403
#define sq(x) (x)*(x)
#define eps 1e-3
typedef pair<int, int> pii;
#define pi acos(-1.0)
const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
inline ll rd() {
	ll x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }

bool zero(double n) {
	return n<eps&&n>-eps;
}
double dis(double x1, double y1, double x2, double y2) {
	return sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))*1.0;
}

double ang(double a, double b, double c) {
	return acos((a*a + b * b - c * c) / (2.0 * a*b));
}

bool check(double n) {
	return zero(n - (int)(n + 0.5000));
}

int main()
{
	//ios::sync_with_stdio(false);
	double x[3], y[3];
	double a, b, c, A, B, C;
	for (int i = 0; i < 3; i++)cin >> x[i] >> y[i];
	double cc = 0.0;
	a = dis(x[0], y[0], x[1], y[1]);
	b = dis(x[0], y[0], x[2], y[2]);
	c = dis(x[1], y[1], x[2], y[2]);
	cc = 0.5*(a + b + c);
	double Sabc = sqrt(1.0*cc*(cc - a)*(cc - b)*(cc - c))*1.0;
	int i, j;
	A = 1.0*ang(a, b, c) / pi; B =1.0*ang(b, c, a) / pi; C = 1.0*ang(c, a, b) / pi;

	for (i = 3; i <= 1000; i++) {
		if (check(A*i) && check(B*i) && check(C*i))break;
	}
	//cout << i << endl;
	double R = a * b*c / (4.0*Sabc);// 外接圓半徑
	double MinS;
	double t = 2.0*pi / i;// 每個圓心角
	MinS = 1.0*R*R*sin(t)*pi / t;// 多邊形面積
	printf("%.6f\n", 1.0*MinS);
    return 0;
}