cf------(round)#1 C. Ancient Berland Circus(几何)
2 seconds
64 megabytes
standard input
standard output
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.
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 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.
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
1.00000000 这道题的题意是: 以一个场地遗迹,呈现多边形,但是不知道具体是几边形,只知道他的三个点,求能包含这三个点的最小多边形的面积:
对于这样的题目: 思路为:
先求出他的外接圆,得到外接圆的半径rr.
(1外接圆的求法:
{
(1) 有给定的坐标我们不难求出三条边的边长,rea,reb,rec;
(2) 又海伦公式得到三角形的面积: 周长cc=(rea+reb+rec)/2.0 面积等于: ss=sqrt(cc*(cc-rea)*(cc-reb)*(cc-rec));
(3) rr=rea*reb*rec/(4*ss); //证明就不详细说了
}
得到外接园的半径之后:
我们再来求出每一条边对应的圆心角a,b,c;
求出a,b,c圆心角的最大公约数st;
这样我们就可以知道他是边数: 2*pi/st;
所以得到最小单位的三角形的面积为Area=rr*rr*sin(st)/2;
总面积只需再剩上他的边数就可以得到.....
代码如下:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double PI = 3.1415926535;
const double esp=0.01;
struct node{
double x,y;
//求两点之间的长度
double solen(node a){
return sqrt((a.x-x)*(a.x-x)+(a.y-y)*(a.y-y));
}
};
double dgcd(double a,double b) //最小公倍数
{
if(a<esp) return b;
if(b<esp) return a;
return dgcd(b,fmod(a,b));
}
int main()
{
node a,b,c;
double rea,reb,rec,Area;
double angle[]; //角度
//freopen("test.in","r",stdin);
scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
rea=a.solen(b);
reb=a.solen(c);
rec=b.solen(c);
//又海伦公式
double cc=(rea+reb+rec)/2.0;
Area=sqrt(cc*(cc-rea)*(cc-reb)*(cc-rec));
//求得外接圆半径r
double rr=rea*reb*rec/(*Area);
angle[]=acos(-rea*rea/(*rr*rr));
angle[]=acos(-reb*reb/(*rr*rr));
angle[]=*PI-angle[]-angle[];
//求出角之间的最大公约数
double ff=angle[];
for(int i=;i<;i++)
ff=dgcd(ff,angle[i]);
//求得是多少边行
printf("%.6lf\n",(rr*rr*PI*sin(ff))/ff);
return ;
}
cf------(round)#1 C. Ancient Berland Circus(几何)的更多相关文章
- Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...
- codforces 1C Ancient Berland Circus(几何)
题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...
- AC日记——codeforces Ancient Berland Circus 1c
1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #includ ...
- CodeForces - 1C:Ancient Berland Circus (几何)
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things ...
- 「CF1C Ancient Berland Circus」
CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...
- Codeforces 1C Ancient Berland Circus
传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...
- C. Ancient Berland Circus(三点确定最小多边形)
题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组 ...
- 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 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
随机推荐
- C语言程序设计现代方法1,2,3章
1:浮点型(float)运算比int慢,并且可能存在舍入误差 如float存储0.1,以后使用可能会变成0.099999999987 2:宏定义只用大写,这是大多数C程序猿遵循的规范! C语言区分大小 ...
- 比Redis更快:Berkeley DB面面观
比Redis更快:Berkeley DB面面观 Redis很火,最近大家用的多.从两年前开始,Memcached转向Redis逐渐成为潮流:而Berkeley DB可能很多朋友还很陌生,首先,我们简单 ...
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
报错提示: ... ld: 6 duplicate symbols for architecture x86_64 clang: error: linker command failed with e ...
- 关于dom ready事件
0.加载完页面,解析完所有标签(不包括执行CSS和JS),并如规范中所说的设置 interactive 和执行每个静态的script标签中的JS,然后触发. 1.没有js,有css,有img,DOMC ...
- CISCO VPN出现网关报错
今天尝试使用发现报错: 重启VPN服务即可
- UVA 11468【AC自动机+DP】
dp[i][j]表示走了i步走到j结点的概率.初始值dp[0][0] = 1.当走到的结点不是单词尾结点时,才能走过去. !end[i]&&last[i] == root时,该结点才可 ...
- Python学习(10)元组
目录 Python 元组 访问元组 修改元组 删除元组 元组运算符 元组索引,截取 无关闭分隔符 元组内置函数 Python 元组 Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组 ...
- HTML <meta> 标签
<meta> 元素可提供有关页面的元信息,元数据总是以名称/值的形式被成对传递的. <meta> 标签位于文档的头部,不包含任何内容. <meta> 标签的属性定义 ...
- c++中vector的学习
根据各种做题,发现数组并不是很适用于各种情况,当涉及到内存占用的时候,数组可能就没有vector的优势了,而vector,动态数组,比较适合某些情况. 接下来看看比较基本的vector用法: 1 #i ...
- Linux socket编程应用学习笔记
参考这个系列吧 http://www.cnblogs.com/wunaozai/tag/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/default.html?page=2 ...