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;
}

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值