C. Ancient Berland Circus

题目连接:

http://www.codeforces.com/contest/1/problem/C

Description

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 Input

0.000000 0.000000

1.000000 1.000000

0.000000 1.000000

Sample Output

1.00000000

Hint

题意

给你一个正多边形上的三个点,然后让你输出一个最小的正多边形面积满足这三个点是这个正多边形的顶点。

题解:

数学题。

给你三个点,很容易算出多边形的半径,R = abc / 4S,abc是三边边长,S是三角形面积。

然后能够构成的最小多边形就是n = pi/gcd(A,B,C)。

gcd是浮点数。

然后强行算一波面积就好了。

代码

#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const double pi = acos(-1.0);
struct node
{
double x,y;
}a,b,c;
double A,B,C;
double gcd(double x, double y) {
while (fabs(x) > eps && fabs(y) > eps) {
if (x > y)
x -= floor(x / y) * y;
else
y -= floor(y / x) * x;
}
return x + y;
}
double dis(node p1,node p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
int main()
{
cin>>a.x>>a.y;
cin>>b.x>>b.y;
cin>>c.x>>c.y;
A = dis(b,c);
B = dis(a,c);
C = dis(a,b);
double p = (A+B+C)/2.0;
double S = sqrt(p*(p-A)*(p-B)*(p-C));
double AA = acos((B*B+C*C-A*A)/(2.0*B*C));
double BB = acos((C*C+A*A-B*B)/(2.0*A*C));
double CC = acos((A*A+B*B-C*C)/(2.0*A*B));
double R = (A*B*C)/(4.0*S);
double n = (pi/(gcd(AA,gcd(BB,CC))));
printf("%.12f\n",n*R*R*sin(2.0*pi/n)/2.0);
}

Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何的更多相关文章

  1. Codeforces Beta Round #37 C. Old Berland Language 暴力 dfs

    C. Old Berland Language 题目连接: http://www.codeforces.com/contest/37/problem/C Description Berland sci ...

  2. 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 ...

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

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

  4. Codeforces Beta Round #1 A,B,C

    A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...

  5. 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 ...

  6. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  7. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  8. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  9. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

随机推荐

  1. Override 和 Overload 的含义和区别

    Override 1.方法重写.覆盖: 2.重写是父类与子类之间多态性的一种表现: 3.方法名,参数,返回值相同: 4.存在于子类和父类之间: 5.修饰为final的方法,不能被重写: Overloa ...

  2. MFC不同工程(解决方案)之间对话框资源的复制与重用方法(转)

    原文转自 https://blog.csdn.net/lihui126/article/details/45556687

  3. java===java基础学习(14)---封装

    package dog; public class Demo4 { public static void main(String []args) { Worker w1= new Worker(&qu ...

  4. 机器学习开源项目精选TOP30

    本文共图文结合,建议阅读5分钟. 本文为大家带来了30个广受好评的机器学习开源项目. 640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1 最近,Mybridge发布了 ...

  5. visual studio 个性化设置

    尼马visual studio 的注释建设的真垃圾 Ctrl+K+C Ctrl+K+U, 通过工具->选项->环境->键盘->命令包含中搜索“注释选定内容”,分配成 Ctrl+ ...

  6. C json实战引擎 一 , 实现解析部分

    引言 以前可能是去年的去年,写了一个 c json 解析引擎用于一个统计实验数据项目开发中. 基本上能用. 去年在网上 看见了好多开源的c json引擎 .对其中一个比较标准的 cJSON 引擎 深入 ...

  7. sql查询语句查询顺序

    一 SELECT语句关键字的定义顺序 SELECT DISTINCT <select_list> FROM <left_table> <join_type> JOI ...

  8. hdu 2389(二分图hk算法模板)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  9. opencv c++实用操作

    像素遍历 对单通道图像的遍历处理 For( int i =0 ; i < grayim.rows; i++) For(int j = 0; j<grayim.cols; j++) Gray ...

  10. 遇见Python.h: No such file or directory的解决方法

    出现No such file or directory的错误,有两种情况,一种是没有Python.h这个文件,一种是Python的版本不对, 可以进入/usr/include/文件夹下的Pythonx ...