Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何
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 计算几何的更多相关文章
- Codeforces Beta Round #37 C. Old Berland Language 暴力 dfs
C. Old Berland Language 题目连接: http://www.codeforces.com/contest/37/problem/C Description Berland sci ...
- 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 ...
- AC日记——codeforces Ancient Berland Circus 1c
1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #includ ...
- 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 ...
- 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 ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
随机推荐
- python基础===多进程
进程线程的区别在进程,线程,协程的区别 linux或者unix有fork()函数,但是不支持win系统. multiprocessing multiprocessing模块是跨平台版本的多进程模块.支 ...
- OGRECave [www]
OGRECave https://github.com/OGRECave
- python爬虫模块之HTML解析模块
这个就比较简单了没有什么好强调的,如果返回的json 就是直接按照键值取,如果是网页就是用lxml模块的html进行xpath解析. from lxml import html import json ...
- C# 网络编程小计 20150202
在学习网络Socket编程之前必须得学会多线程编程,这个是经常会用的到 可参考:http://www.cnblogs.com/GIS_zhou/articles/1839248.html System ...
- python 结束练习
1.文件操作有哪些模式?请简述各模式的作用 r 只读模式 r+ 读写 rb w 只写模式 w+ 写读 wb x 只写模式 x+ 写读 xb a 追加模式 a+ 写读 ab 2.s = '**hello ...
- 都是干货---真正的了解scrapy框架
去重规则 在爬虫应用中,我们可以在request对象中设置参数dont_filter = True 来阻止去重.而scrapy框架中是默认去重的,那内部是如何去重的. from scrapy.dupe ...
- python 单例模式4中实现方法
python实现单例模式的方法: 1. 使用模块 python的模块在第一次导入时会生成.pyc文件,当第二次导入时就会直接加载.pyc文件,而不会再次执行模块代码. 只需将其单独放在一个模块里,并创 ...
- hdu 1495(BFS)
非常可乐 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Go语言的基准测试简单示例
测试了三个从数字转换为字符的性能, 高手的感觉.... package listing28_test import ( "fmt" "testing" &quo ...
- cssBase.css你应该有一个
@charset "utf-8"; /*! * @名称:base.css * @功能:1.重设浏览器默认样式 * 2.设置通用原子类 */ /* 防止用户自定义背景颜色对网页的影响 ...