C. Ancient Berland Circus
time limit per test

2 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

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.

Sample test(s)
Input
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
Output
1.00000000

这道题的题意是: 以一个场地遗迹,呈现多边形,但是不知道具体是几边形,只知道他的三个点,求能包含这三个点的最小多边形的面积:
对于这样的题目: 思路为:
先求出他的外接圆,得到外接圆的半径rr.
(1外接圆的求法:

(1) 有给定的坐标我们不难求出三条边的边长,rea,reb,rec;
(2) 又海伦公式得到三角形的面积: 周长cc=(rea+reb+rec)/2.0 面积等于: ss=sqrt(cc*(cc-rea)*(cc-reb)*(cc-rec));
(3) rr=rea*reb*rec/(4*ss); //证明就不详细说了

得到外接园的半径之后:
我们再来求出每一条边对应的圆心角a,b,c;
求出a,b,c圆心角的最大公约数st;
这样我们就可以知道他是边数: 2*pi/st;
所以得到最小单位的三角形的面积为Area=rr*rr*sin(st)/2;
总面积只需再剩上他的边数就可以得到.....
代码如下:
 #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double PI = 3.1415926535;
const double esp=0.01;
struct node{
double x,y;
//求两点之间的长度
double solen(node a){
return sqrt((a.x-x)*(a.x-x)+(a.y-y)*(a.y-y));
}
};
double dgcd(double a,double b) //最小公倍数
{
if(a<esp) return b;
if(b<esp) return a;
return dgcd(b,fmod(a,b));
}
int main()
{
node a,b,c;
double rea,reb,rec,Area;
double angle[]; //角度
//freopen("test.in","r",stdin);
scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
rea=a.solen(b);
reb=a.solen(c);
rec=b.solen(c);
//又海伦公式
double cc=(rea+reb+rec)/2.0;
Area=sqrt(cc*(cc-rea)*(cc-reb)*(cc-rec));
//求得外接圆半径r
double rr=rea*reb*rec/(*Area);
angle[]=acos(-rea*rea/(*rr*rr));
angle[]=acos(-reb*reb/(*rr*rr));
angle[]=*PI-angle[]-angle[];
//求出角之间的最大公约数
double ff=angle[];
for(int i=;i<;i++)
ff=dgcd(ff,angle[i]);
//求得是多少边行
printf("%.6lf\n",(rr*rr*PI*sin(ff))/ff);
return ;
}

cf------(round)#1 C. Ancient Berland Circus(几何)的更多相关文章

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

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

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

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

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

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

  4. CodeForces - 1C:Ancient Berland Circus (几何)

    Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things ...

  5. 「CF1C Ancient Berland Circus」

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

  6. Codeforces 1C Ancient Berland Circus

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

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

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

  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. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

随机推荐

  1. 【转】JSP总结

    day1 JSP 定义:     1)Java Server Page, Java EE 组件,本质上是 Servlet.     2)运行在 Web Container.接收 Http Reques ...

  2. Give My Text Back

    Give My Text Back 标签(空格分隔): 算法 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 To prepare for the English exa ...

  3. BP神经网络求解异或问题(Python实现)

    反向传播算法(Back Propagation)分二步进行,即正向传播和反向传播.这两个过程简述如下: 1.正向传播 输入的样本从输入层经过隐单元一层一层进行处理,传向输出层:在逐层处理的过程中.在输 ...

  4. sql语句查询出表里符合条件的第二条记录的方法

    创建用到的表的SQL CREATE TABLE [dbo].[emp_pay]( [employeeID] [int] NOT NULL, [base_pay] [money] NOT NULL, [ ...

  5. SQL语句like子句中的转义符

    如果想在SQL LIKE里查询有下划线'_'或是'%'等值的记录,直接写成like 'XXX_XX',则会把'_'当成是like的通配符.SQL里提供了 escape子句来处理这种情况,escape可 ...

  6. Field+offset(len)

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  7. [SAP ABAP开发技术总结]结构复用(INCLUDE)

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. CALayer总结(三)

    CPU VS GPU 动画和屏幕上组合的图层实际上被一个单独的进程管理,而不是你的应用程序.这个进程就是所谓的渲染服务.在iOS5和之前的版本是SpringBoard进程(同时管理着iOS的主屏).在 ...

  9. mysql概要(十一)存储引擎

    1.数据库对同样的数据可以不同的方式存储和管理,每种方式对应一种引擎. 1.1定义: 2.引擎种类的特点:

  10. 老笔记本_Win7_U盘_ReadyBoost

    老笔记本 Win7 U盘 ReadyBoost 值得尝试