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. Java中List.remove报UnsupportedOperationException异常

    今天项目中有个需求场景: A和B都是List,而B是A的子集,现在想求A和B的差集. 想到了List中提供的removeAll()方法可以求得差集,但是结果确报了UnsupportedOperatio ...

  2. font awesome (图标字体库)

    Font Awesome fa是什么? 图标字体库和CSS框架 怎么用? <link rel="stylesheet" href="https://cdn.boot ...

  3. 【学员管理系统】0x02 学生信息管理功能

    [学员管理系统]0x02 学生信息管理功能 写在前面 项目详细需求参见:Django项目之[学员管理系统] Django框架大致处理流程 捋一下Django框架相关的内容: 浏览器输入URL到页面展示 ...

  4. Django之restframework2视图三部曲

    视图三部曲 下面我来来看restframework是如何将冗余的代码一步步的进行封装. 这里主要用到的是多继承 第一步mixin类编写视图 AuthorModelSerializer: class A ...

  5. 我的Android进阶之旅------>Android中StateListDrawable支持的状态

    Android中StateListDrawable支持的状态 android:state_active 代表是否处于激活状态 android:state_checked  代表是否处于已勾选状态 an ...

  6. 4.对urls.py的解释

    解释: 路由配置文件(URL分发器),它的本质是URL模式以及要为该URL模式调用的视图函数之间的映射表.就是以这种方式告诉Django对于每个URL的处理类.Django启动的时候回去加载urls. ...

  7. 如何使用Django实现用户登录验证

    最初开始搞用户登录验证的时候感觉没什么难的,不就是增删改查中的查询数据库么,但是还是遇到许多小问题,而且感觉在查询数据库的时候,要把前端的数据一条一条的进行比对,会导致我的代码很丑,而且方式很不智,所 ...

  8. Linux入门基础(四)——磁盘管理

  9. BAPI_SALESORDER_CREATEFROMDAT2 创建退货SO

    BAPI_SALESORDER_CREATEFROMDAT2创建退货订单时,会出现以下错误:不允许业务对象 BUS2032 和销售凭证类别 H 的组合. 解决办法: 采用/原BAPI的内嵌BAPI: ...

  10. valuestack,stackContext,ActionContext.之间的关系以及action的数据在页面中取得的方法

     转自:http://blog.csdn.net/quechao123/article/details/4406148 1.三者之间的关系如下图所示: 2.action的数据在页面中取得的方法 在st ...