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

题意:有一个正多边形,现在我们只知道其中3个点的坐标,求原多边形的面积,如果有多个满足,求最小面积。

思路:已知三点,我们可以确定外接圆,然后显然,我们需要多边形的边长最大(或者对于的圆心角最大),但是由于有钝角或者锐角,求最大边长可能要讨论。所以我们求最大圆心角。

可能推论:最大圆心角=三角形的三条边对应的圆心角的gcd。然后就得到了有2pi/gcd边。blabla。

(得到三个角的时候,第三个角=2pi-A-B。而直接求会WA。。。

#include<bits/stdc++.h>
using namespace std;
const double eps=1e-;
const double pi=acos(-1.0);
double Gcd(double a,double b)
{
while(fabs(a)>eps&&fabs(b)>eps){
if(a>b) a-=floor(a/b)*b;
else b-=floor(b/a)*a;
}
return a+b;
}
double x[],y[],L1,L2,L3,S,R;
double dist(int a,int b){
return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}
double area(){
double p=(L1+L2+L3)/2.0; return sqrt(p*(p-L1)*(p-L2)*(p-L3));
}
int main()
{
for(int i=;i<=;i++) scanf("%lf%lf",&x[i],&y[i]);
L1=dist(,); L2=dist(,); L3=dist(,);
S=area(); R=L1*L2*L3/(S*);
double A=acos((R*R+R*R-L3*L3)/(*R*R));
double B=acos((R*R+R*R-L2*L2)/(*R*R));
double C=*pi-A-B;
double ang=Gcd(Gcd(A,B),C);
double ans=pi/ang*R*R*sin(ang);
printf("%.6lf\n",ans);
return ;
}

CodeForces - 1C:Ancient Berland Circus (几何)的更多相关文章

  1. Codeforces 1C Ancient Berland Circus

    传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...

  2. codforces 1C Ancient Berland Circus(几何)

    题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...

  3. cf------(round)#1 C. Ancient Berland Circus(几何)

    C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...

  4. AC日记——codeforces Ancient Berland Circus 1c

    1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #includ ...

  5. Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何

    C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...

  6. C. Ancient Berland Circus(三点确定最小多边形)

    题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组 ...

  7. 「CF1C Ancient Berland Circus」

    CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...

  8. Codeforces 1 C. Ancient Berland Circus-几何数学题+浮点数求gcd ( Codeforces Beta Round #1)

    C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...

  9. codeforces 1C (非原创)

    C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...

随机推荐

  1. iOS 平台如何使用 TestFlight 进行 Beta 测试

    使用 TestFlight,你可以向测试人员发布你 App 的 prerelease 版本来收集反馈信息,为将来发布 App 的正式版做准备.现在 TestFlight 是一个可选功能,你也可以不使用 ...

  2. Android插件化(使用Small框架)

    github: https://github.com/cayden/MySmall Android插件化(使用Small框架) 框架源代码 1. Create Project File->New ...

  3. 【BZOJ4154】[Ipsc2015]Generating Synergy KDtree

    [BZOJ4154][Ipsc2015]Generating Synergy Description 给定一棵以1为根的有根树,初始所有节点颜色为1,每次将距离节点a不超过l的a的子节点染成c,或询问 ...

  4. java并发编程基础---Sky

    1.线程及启动和终止 1.1 线程 -进程/优先级 操作系统调度的最小单元是线程,线程是轻量级进程. 线程优先级由setPriority(int)方法来设置,默认优先级是5,等级1~10.等级越高分的 ...

  5. Jquery点击事件出发顺序

    鼠标点击触发事件执行顺序: mouse down -> mouse up -> click 键盘点击出发事件执行顺序: 点击后马上抬起:key down -> key press - ...

  6. python-安装 pip

    https://pip.pypa.io/en/stable/installing/ wget https://bootstrap.pypa.io/get-pip.py python get-pip.p ...

  7. 特性,批次特性建立的BAPI函數

    [转http://taijizhang.blog.163.com/blog/static/176071381201442225514453/] SAP特性,物料特性,批次特性建立的BAPI函數 类的T ...

  8. python webserver客户端

    1.库 suds库,只能做webserver客户端,轻量化,使用方便.安装使用pip. 2.使用 如有webserver情况如下: url:http://10.110.35.41:8980/wsser ...

  9. PHP eval函数使用介绍

    eval()函数中的eval是evaluate的简称,这个函数的作用就是把一段字符串当作PHP语句来执行. 复制代码代码如下: eval("echo'hello world';") ...

  10. 每天一个Linux命令(19)find命令_初识

    Linux下find命令在目录结构中搜索文件,并执行指定的操作.     (1)用法: 用法: find pathname    -option      [-print | -exec | -ok] ...