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. perl模拟登录(1)

    use WWW::Mechanize; my $ua = WWW::Mechanize->new(); $ua->post('http://localhost/dvwa/DVWA-mast ...

  2. 【SCOI2010】维护序列

    NOI2017的简化版…… 就是维护的时候要想清楚怎么讨论. #include<bits/stdc++.h> #define lson (o<<1) #define rson ...

  3. JSP(3) - 9个JSP内置对象 - 小易Java笔记

    1.9个JSP内置对象 内置对象引用名称     对应的类型 request HttpServletRequest response HttpServletResponse config Servle ...

  4. C语言string转int

    再不用atoi函数接口时,将字符串型转换成整型. 例如:将字符串型“158”转换成整型158 int String2Int(char * buff) { ; ; '; index++) { value ...

  5. redis使用教程

    一.redis 的安装 官方就是个坑:只说make一下即可用,确实可以用,我以为装好了,结果好多问题: 安装步骤:make =>  make test  => make install 1 ...

  6. 1:django models

    重温django model 1:many-to-many 的额外属性 一般情况下,many-to-many直接就可以满足我们的要求,考虑这样一种情况: 音乐家和乐团是many-to-many的关系, ...

  7. 用淘宝镜像cnpm代替npm

    安装淘宝镜像cnpm: $ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org 然后就大部分可以用cnpm来代替np ...

  8. AC日记——[HNOI2010]BOUNCE 弹飞绵羊 洛谷 P3203

    [HNOI2010]BOUNCE 弹飞绵羊 思路: SBlct: 代码: #include <bits/stdc++.h> using namespace std; #define max ...

  9. 编写简单的spring mvc程序,在tomcat上部署

    编写简单的spring mvc程序,在tomcat上部署 1 用java 配置spring mvc ,可以省去web.xmlpackage hello;import org.springframewo ...

  10. SpringMVC组件配置

    web.xml . springmvc-servlet.xml 配置SpringMVC四大组件. web.xml 配置前端控制器:前端控制器就是个servlet <!-- 配置前端控制器 --& ...