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. C#中() =>是什么意思

    如题C#中() =>是什么意思,比如 public ICommand AddCommand { get { if (this.addCommand == null) this.addComman ...

  2. Examples For When-Validate-Item trigger In Oracle Forms

    The following example finds the commission plan in the COMMPLAN table, based on the current value of ...

  3. json和jsonp的传输方式

    jsonp传输会解决跨域的问题 $.ajax({ async: false, /* url: "http://127.0.0.1:8080/2015020601/background/mea ...

  4. C#控制台->>四则运算

    用户需求: 要求编写一个0-10之间的整数进行四则运算,程序能接收输入的整数答案,并判断对错,程序结束时,统计出答对.答错的题目数量!并且0-10的整数是随机生成的,用户可以用键盘输入来选择四则运算中 ...

  5. 网站安全扫描工具--Netsparker的使用

    Netsparker是一款安全简单的web应用安全漏电扫描工具.该软件功能非常强大,使用方便.Netsparker与其他综合 性的web应用安全扫描工具相比的一个特点是它能够更好的检测SQL Inje ...

  6. 苹果原生NSURLSession的上传和下载

    关于NSURLSession的上传和下载 在iOS7.0后,苹果公司新推出了一个NSURLSession来代替NSURLConnection.NSURLConnection默认是在 主线程执行的.而N ...

  7. python进程、线程、协程(转载)

    python 线程与进程简介 进程与线程的历史 我们都知道计算机是由硬件和软件组成的.硬件中的CPU是计算机的核心,它承担计算机的所有任务. 操作系统是运行在硬件之上的软件,是计算机的管理者,它负责资 ...

  8. Deep Learning Workbench Installation Notes

    1. ROS Indigo (30 min) Just flow ROSWiki: http://wiki.ros.org/indigo/Installation/Ubuntu NOW simply ...

  9. Object-C: 枚举

    摘自:http://coffeeandsandwich.com/?p=8 在 iOS 6 和 Mac OS X 10.8 以前,定义枚举类型的方式如下: typedef enum the_enum_n ...

  10. JS学习笔记(四) 正则表达式(RegExp对象)

    参考资料: 1. http://www.w3school.com.cn/js/js_obj_regexp.asp ☂ 知识点: ☞ RegExp是正则表达式的缩写. ☞ RegExp是一种模式,用于在 ...