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. write-ups

    https://github.com/MarioVilas/write-ups https://github.com/Deplorable-Mountaineer/Robot_Dynamite htt ...

  2. Redis 主从部署

    Redis 主从部署 http://www.xuchanggang.cn/archives/978.html

  3. [How to]如何自定义plist文件和读取plist文件内容

    1.简介 plist作为IOS的固化文件,就好比java中properties文件,但是在IOS中plist是可读写的. 本文将介绍自定义静态的plist文件. 2.自定义静态plist文件 右击你的 ...

  4. mysql设置服务器编码

    今天写java程序的时候出现了插入mysql数据中文乱码问题,确定数据库和表的编码都已指定utf-8.百度后得知mysql安装后需设置服务器编码,以下是解决方法(ubuntu; mysql 5.6.2 ...

  5. AtomicReference 和 volatile 的区别

    顾名思义,就是不会被打断!!!!!! https://www.cnblogs.com/lpthread/p/3909231.html java.util.concurrent.atomic工具包,支持 ...

  6. gradle eclipse 配置

    http://blog.csdn.net/caolaosanahnu/article/details/17022321 从gradle官网下载 解压,配置环境变量,gradle -v 验证 gradl ...

  7. [转]6个HelloWorld

    原文地址:点击打开链接 转这个帖子,是因为看了这个帖子使我明白了一个道理:一旦你发散自己的思维,激发自己的创意,就会发现原来编程是这么的好玩. 原文标题为<6个变态的C语言Hello World ...

  8. Binary Tree Postorder Traversal——重要的基本的算法

    Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...

  9. 通过kubeadm安装kubernetes 1.7文档记录[docker容器方式]

    参照了网上N多文档,不一一列表,共享精神永存!!!! ================================================== 获取所有安装包 安装包分为两类,rpm安装包 ...

  10. Laravel 下配置 Redis 让缓存、Session 各自使用不同的 Redis 数据库

    为什么要这样做? 默认情况下,Redis 服务会提供 16 个数据库,Laravel 使用数据库 0 (请见 Redis 文档)作为缓存和 Session 的存储. 在使用的过程中觉得这个默认的设置挺 ...