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. java===java基础学习(16)---final

    final-----概念 1.当不希望父类的某个方法被子类覆盖(override)时,可以用final关键字修饰. 2.当不希望类的某个变量的值被修改时,可以用final修饰.如果要用final,则必 ...

  2. java===java习题---Josephu问题

    package testbotoo; /** * * @author */ public class Demo4 { public static void main(String[] args) { ...

  3. python基础===pendulum '''Python datetimes made easy.'''

    https://pypi.python.org/pypi/pendulum Pendulum的一大优势是内嵌式取代Python的datetime类,可以轻易地将它整合进已有代码,并且只在需要的时候才进 ...

  4. Linux内核【链表】整理笔记(2) 【转】

    转自:http://blog.chinaunix.net/uid-23069658-id-4725279.html 关于链表我们更多时候是对其进行遍历的需求,上一篇博文里我们主要认识了一下和链表操作比 ...

  5. Chrome控制台的妙用之使用XPATH

    谷歌浏览器,对于作为程序员的我们来说可以是居家必备了,应该用的相当的熟悉了,我们用的最多的应该是network选项吧,一般用来分析网页加载的请求信息,比如post参数之类的,这些基本的功能基本上够用了 ...

  6. REST,Web 服务,REST-ful 服务

    介绍 REpresentational State Transfer (REST) 是一种架构原则,其中将 web 服务视为资源,可以由其 URL 唯一标识.RESTful Web 服务的关键特点是明 ...

  7. C++变量类型转换

    1:int转换为CString CString str; str.Format("As string: %d", int); 2:double转换为CString CString ...

  8. 关于自适应屏幕,设置子元素浮动,父div不能包裹子div,子元素中内容溢出的问题。

    设置HTML适应不同分辨率的屏幕. 需求结构如下: HTML结构代码如下(只是其中一条): <body> <div class="content">< ...

  9. jboss和tomcat有什么不同

    2.tomcat 是 JSP/Servlet 容器jboss 是 JEE 容器,JEE 包括JSP/Servlet,JMS, EJB,JAX-WS,JAX-RS,CDI等等, tomcat是完全开源, ...

  10. LeetCode解题报告—— 4Sum & Remove Nth Node From End of List & Generate Parentheses

    1. 4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + ...