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. Lumen开发:lumen源码解读之初始化(1)——app实例

    版权声明:本文为博主原创文章,未经博主允许不得转载. 有些注释来着原文的百度翻译,可以有些难理解或者奇怪,我后面会根据自己的理解做调整的哈!!!不喜勿喷,层主英语不过关... 先来看看入口文件publ ...

  2. 第二课 创建http server

    nodejs 不需要单独安装服务器软件 tomcat .apache. iis 看下面的代码创建了http服务器,并输出一些简单的响应内容 //引入http 模块 var http = require ...

  3. maven3 org.codehaus.plexus.classworlds.launcher.launcher 找不到或无法加载主类

    maven3 org.codehaus.plexus.classworlds.launcher.launcher 找不到或无法加载主类 嗯,网上很多资料说是路径的问题,确实是有可能是路径的问题,而且还 ...

  4. 我的Android进阶之旅------>四种呼叫转移场景

    运行商为我们提供了如下4中呼叫转移场景: 1.始终进行呼叫转移:不管当前手机处于何种状态,来电都会被转移到指定的电话号码上.在使用这种呼叫转移时应当非常小心,如果启用了这种呼叫转移,你可就永远也接不着 ...

  5. 拉普拉斯分布(Laplace distribution)

    拉普拉斯分布的定义与基本性质 其分布函数为 分布函数图 其概率密度函数为 密度函数图 拉普拉斯分布与正太分布的比较 从图中可以直观的发现拉普拉斯分布跟正太分布很相似,但是拉普拉斯分布比正太分布有尖的峰 ...

  6. Iptalbes练习题(三)

    场景需求: (1)员工在公司内部(192.168.124.0/24 ,192.168.122.0/24 )能访问服务器上任何服务 (2)当员工出差,通过VPN连接到公司 (3)公司门户网站允许公网访问 ...

  7. Iptalbes练习题(一)

    实验环境: KVM 虚拟机 centos6.7 test1:192.168.124.87  test2:192.168.124.94 场景一: 要求:1.对所有地址开放本机的tcp(80.22.10- ...

  8. Chrome Extension 扩展程序 小白入门

    Chrome Extension 扩展程序 前请说明:本文适用于之前从来没有接触过chrome extension扩展程序的同学~ 编写demo 创建项目文件夹chrome_ext_demo,在项目根 ...

  9. 每天一个Linux命令(26)chown命令

          chown命令改变某个文件或目录的所有者和所属的组,该命令可以向某个用户授权,使该用户变成指定文件的所有者或者改变文件所属的组.     (1)用法:     用法:  chown [选项 ...

  10. Java多线程系列 JUC锁06 Condition条件

    Condition介绍 Condition中提供了一组类似于Object中的监视器方法.与Lock配合可以完成等待通知模式. Lock lock = new ReentrantLock(); Cond ...