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. EnumWindows function

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx Enumerates all top-l ...

  2. 青岛理工大学第五届ACM交流赛 部分题解

    A:后缀维护si*pi的最小值,查询的时候二分,判断后缀和当前两个部分就行. #include <bits/stdc++.h> using namespace std; typedef l ...

  3. Beaglebone Black - 控制 BBB 板上的 LED 灯

    BBB 的板上有五个 LED 灯,一个电源,四个其他指示灯,usr0 至 usr3 .这次学习是控制 usr0 至 3 让它们亮着,熄灭,闪.算是个 Hello World 实验.非常简单. 需要的材 ...

  4. plot bar chart using python

    Example import matplotlib.pyplot as plt import plotly.plotly as py # Learn about API authentication ...

  5. Object-c:两种文件读写的对比

    一.读写方法对比:(主要针对本地读取本地文件) 方式\操作 读 写 非URL方式 stringWithContentsOfFile writeToFile URL方式 stringWithConten ...

  6. CSS中应用position的absolute和relative的属性制作浮动层

    我的浮动层结构大概如下: <div id="father"> <div id="son"> </div> </div& ...

  7. 2dx中文乱码问题

    我们的代码里面有一个bug 为了跟之前兼容的策划导表工具兼容 导表工具导出的excel全部都是ansi的 为了兼容就只能手动改成utf 8 无bom格式 后来策划嫌烦了 就让在程序段处理这个 研究了好 ...

  8. Spring XML配置实现AOP

    1:  首先我们要定义 配置成切面的类 package cn.gbx.example; import org.aspectj.lang.ProceedingJoinPoint; import org. ...

  9. 2013/7/17 HNU_训练赛5

    sgu 542 Gena vs Petya sgu 543 Cafe 题意:有N组人需要被分配到某些固定了人数的桌子上,其中ai表示第i组有多少个人,安排作为需要符合如下安排:某一组的人员不能够单独在 ...

  10. iOS - AutoLayout

    前言 NS_CLASS_AVAILABLE_IOS(6_0) @interface NSLayoutConstraint : NSObject @available(iOS 6.0, *) publi ...