Ancient Berland Circus

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.

Input

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

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.

 

Examples

Input

0.000000 0.000000

1.000000 1.000000

0.000000 1.000000

Output


1.00000000

 题目大意:给你一个正多边形的三个顶点,现在让你求出能用这三个顶点构成的最小的正多边形的面积是多少

思路:既然是正多边形,所以这个多边形的所有顶点一定都在它的外接圆上,所以我们可以先求出由三个顶点构成的三角形的外接圆的半径,然后求出每两条边所对应的圆心角,三个圆心角的最大公约数即为这个最小正多边形能分解成的最小三角形所对应的圆心角,然后可以得到有多个这样的三角形,再得出每个三角形的面积即为正多边形的面积

涉及公式:第一个是如何求三角形外接圆的半径:r=a*b*c/(4*s)

                  第二个是余弦公式求角acos(a)=(b*b+c*c-a*a)/(2*b*c)

这里说明一点,不可以直接用余弦公式求出三个角,假如出现钝角,则余弦值为负,那得到的答案就不正确了

然后就是慢慢实现上面过程即可

代码:

/*
题目大意:现在给你三个点为正多边形的三个顶点,现在问你以这三个顶点所围成的最小的正多边形的面积是多少

思路:既然是正多边形,那么其顶点一定都在这个正多边形的外接圆上
所以我们可以通过这三个点确定一个外接圆
*/
#include<set>
#include<map>
#include<ctime>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f
#define bug  printf("bug\n")
const int maxn=1e6+10;
const double pi=acos(-1.0);
const double esp=1e-6;
const int N=2e2+10;
struct point
{
    double x,y;
};
struct line
{
    point st,ed;
    double k,b;
};
int sign(double x)
{
    if(fabs(x)<esp)
        return 0;
    return x>0?1:-1;
}
double getk(line l)
{
    if(l.st.x==l.ed.x)///斜率不存在
        return inf;
    return (l.ed.y-l.st.y)/(l.ed.x-l.st.x);
}
double getb(line l)
{
    return l.ed.y-l.k*l.ed.x;
}
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double cmult(point a,point b,point c)///叉积
{
    return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
double pmult(point a,point b)///点积 这里的ab表示的是向量
{
    return a.x*b.x+a.y*b.y;
}
point a[121];
double gcd( double a,double b)
{
    return a<0.01?b:gcd(fmod(b,a),a);
}
int main()
{
    while(scanf("%lf%lf%lf%lf%lf%lf",&a[0].x,&a[0].y,&a[1].x,&a[1].y,&a[2].x,&a[2].y)!=EOF)
    {
        double l1=dis(a[0],a[1]);
        double l2=dis(a[0],a[2]);
        double l3=dis(a[1],a[2]);
        double s=fabs(cmult(a[0],a[1],a[2]))/2.0;
        ///三角形外接圆半径为abc/(4s)
        double r=l1*l2*l3/(4.0*s);
        ///计算三边所对应的圆心角为多少
        double a1=acos((r*r*2-l1*l1)/(2.0*r*r));
        double a2=acos((r*r*2-l2*l2)/(2.0*r*r));
        double a3=2*pi-a1-a2;
        ///求三角的最大公约数即为最小正多形对应的圆心角
        double gcda=gcd(gcd(a1,a2),a3);
        ///得到最小正多边形的圆心角后计算面积,
        ///因为都是同样的,所以我们计算出一个三角形的圆心角后就可以知道有多少个这样的三角形,计算出一个的面积后得到所有的面积
        double mins=0.5*sin(gcda)*r*r;
        printf("%.6lf\n",mins*(2*pi/gcda));
    }
    return 0;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值