cf------(round)#1 C. Ancient Berland Circus(几何)
C. Ancient Berland Circus
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
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.
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 test(s)
Input
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
Output
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;
总面积只需再剩上他的边数就可以得到.....
代码如下:
1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 using namespace std;
5 const double PI = 3.1415926535;
6 const double esp=0.01;
7 struct node{
8 double x,y;
9 //求两点之间的长度
10 double solen(node a){
11 return sqrt((a.x-x)*(a.x-x)+(a.y-y)*(a.y-y));
12 }
13 };
14 double dgcd(double a,double b) //最小公倍数
15 {
16 if(a<esp) return b;
17 if(b<esp) return a;
18 return dgcd(b,fmod(a,b));
19 }
20 int main()
21 {
22 node a,b,c;
23 double rea,reb,rec,Area;
24 double angle[3]; //角度
25 //freopen("test.in","r",stdin);
26 scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
27 rea=a.solen(b);
28 reb=a.solen(c);
29 rec=b.solen(c);
30 //又海伦公式
31 double cc=(rea+reb+rec)/2.0;
32 Area=sqrt(cc*(cc-rea)*(cc-reb)*(cc-rec));
33 //求得外接圆半径r
34 double rr=rea*reb*rec/(4*Area);
35 angle[0]=acos(1-rea*rea/(2*rr*rr));
36 angle[1]=acos(1-reb*reb/(2*rr*rr));
37 angle[2]=2*PI-angle[0]-angle[1];
38 //求出角之间的最大公约数
39 double ff=angle[0];
40 for(int i=1;i<3;i++)
41 ff=dgcd(ff,angle[i]);
42 //求得是多少边行
43 printf("%.6lfn",(rr*rr*PI*sin(ff))/ff);
44 return 0;
45 }
- Nginx 负载均衡的Cache缓存批量清理的操作记录
- DotNet软件开发框架
- Nginx通过https方式反向代理的简单实现
- 再论IBatisNet + Castle进行项目的开发
- 利用xml轻松读取web.config中的用户自定义节
- 分布式监控系统Zabbix-3.0.3-完整安装记录(3)-监控nginx,php,memcache,Low-level discovery磁盘IO
- python报错问题解决:'ascii' codec can't encode character
- 利用message queue实现aspx与winform通信, 并附完整示例
- 10招步骤保护IIS服务器安全
- Haproxy+Keepalived高可用环境部署梳理(主主和主从模式)
- Android-Universal-Image-Loader 图片异步加载类库的使用
- 工作组模式下专用队列(Private Queue)如何引用远程队列路径
- haproxy反向代理环境部署(http和https代理)
- 网站速度优化模块HttpCompressionModule
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 几道暑期实习笔试题
- Java自动化测试(selenium 22)
- linux 实现双网卡绑定单个IP——team篇
- Eclipse华丽转身之控件表格工厂
- 面试常考知识点总结——面试必看
- linux 实现双网卡绑定单个IP——bond篇
- Hacking with iOS: SwiftUI Edition - 愿望清单项目(一)
- 重拾Java Web应用的基础体系结构
- 使用SAP C4C自定义BO实现自定义的Number Range
- 限流算法简介及Guava RateLimiter令牌桶限流介绍
- K8S的名称空间创建&&版本的升级、回滚操作
- SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
- SAP WebClient UI One Hit Navigation的实现方法
- 【打包构建】Mac下使用expect实现执行sudo命令时自动输入密码
- ASP.NET Core 奇淫技巧之SPA部署