codeforces 1C (非原创)
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
题目大意:给出三个点,求出以这三个点为定点的最小正多边形。
求最小正多边形,边数越多,面积越大,所以要是求得的多边形的边尽量的小。
由三个点组成的三角形,可以确定一个外接圆,那么正多边形的所有的定点应该都在圆上,求出三边对应的圆心角,找出圆心角的最大公约数,也就得到了多边形的最小的边数。
防止钝角的情况,边长最长的对应的圆心角 = 2*PI - 其他两个圆心角。
r=a*b*c/(4*s)求出外接圆的面积,然后通过正弦定理求出三角形三个边各自的圆心角,然后利用求gcd函数求出A,B,C最大公约数。
由于三角形每条边所对应的圆心角都是正多边形圆心角的整数倍,故n=2*pi/gcd(A,B,C),然后正多边形的面积便是n个相同的三角形的面积了,其中每个三角形面积为r*r/2*sin(p),正多边形面积即可求出.
即: S = 2*PI/p * 1/2*r*r*sin(p) = PI*r*r*sin(p)/p
附代码:
1 #include <cstdio>
2 #include <cstring>
3 #include <cmath>
4 #include <algorithm>
5 using namespace std ;
6 const double PI = acos(-1.0);
7 const double eqs = 0.01;
8 double gcd(double a,double b)
9 {
10 return a < eqs ? b : gcd(fmod(b,a),a);
11 }
12 int main()
13 {
14 double x1 , y1 , x2 , y2 , x3 , y3 ;
15 double a , b , c , p , s , r , k ;
16 double A , B , C ;
17 scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3) ;
18 a = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;
19 b = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) ;
20 c = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) ;
21 p = ( a + b + c ) / 2.0 ;
22 s = sqrt( p * (p-a) * (p-b) * (p-c) ) ;
23 r = a * b * c / ( 4 * s ) ;
24 if( a > c )
25 {
26 k = a ; a = c ; c = k ;
27 }
28 if( b > c )
29 {
30 k = b ; b = c ; c = k ;
31 }
32 A = 2 * asin(a/(2*r)) ; //正弦定理
33 B = 2 * asin(b/(2*r)) ;
34 C = 2 * PI - A - B ;
35 //printf("%lf %lf %lf\n", A, B, C) ;
36 p = gcd(A,B);
37 p = gcd(p,C) ;
38 //printf("%lf %lf\n", r, p) ;
39 printf("%.6lf\n", PI*r*r*sin(p)/p ) ;//1/2*a*b*sinc 三角形已知两边一角的面积公式
40 return 0;
41 }
参考博客:http://blog.csdn.net/winddreams/article/details/42532203
codeforces 1C (非原创)的更多相关文章
- codeforces 6E (非原创)
E. Exposition time limit per test 1.5 seconds memory limit per test 64 megabytes input standard inpu ...
- Linux下high CPU分析心得【非原创】
非原创,搬运至此以作笔记, 原地址:http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html 1.用top命令查看哪个进程占用CPU高ga ...
- CSS样式命名整理(非原创)
非原创,具体出自哪里忘了,如果侵害您的利益,请联系我. CSS样式命名整理 页面结构 容器: container/wrap 整体宽度:wrapper 页头:header 内容:content 页面主体 ...
- 非原创。使用ajax加载控件
非原创.来自博客园老赵. public class ViewManager<T> where T : System.Web.UI.UserControl { private System. ...
- Java 表达式解析(非原创)
因项目需要,在网上找来一套表达式解析方法,由于原来的方法太过于零散,不利于移植,现在整理在同一文件内: 文件中包含5个内部类,源码如下: import java.util.ArrayList; imp ...
- Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创)
Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创) 由于java interface中声明的字段在编译时会自动加上static final的修饰符,即声明为常量.因而inter ...
- 用RD,GR,BL三个方法内代码生成一张图片(非原创,我只是完整了代码)
我公开以下图片的源代码,,是ppm格式的,,自己找到能打开的工具.. (非原创,我加工的代码,可直接执行运行输出,缩略图能看到效果) 这是原博客 http://news.cnblogs.com/n/ ...
- tp5.1 phpspreadsheet- 工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西,)
phpspreadsheet-工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西)1. composer require phpoffice/phpspreadsheet2. 看最下面的两 ...
- Vue 仿QQ左滑删除功能(非原创)
非原创,摘选来源:http://www.jb51.net/article/136221.htm. 废话不多说,相当实用,先记录. Html代码: <div class="contain ...
- 老男孩Django笔记(非原创)
.WEB框架 MVC Model View Controller 数据库 模板文件 业务处理 MTV Model Template View 数据库 模板文件 业务处理 ############## ...
随机推荐
- Vue的核心思想
Vue的核心思想主要分为两部分: 1.数据驱动 2.组件系统 1.数据驱动 在传统的前端交互中,我们是通过Ajax向服务器请求数据,然后手动的去操作DOM元素,进行数据的渲染,每当前端数据交互变化时 ...
- Http中的options请求
引自:https://www.jianshu.com/p/5cf82f092201.https://www.cnblogs.com/mamimi/p/10602722.html 一.options是什 ...
- jmeter---线程组执行顺序记录
一.默认未勾选测试计划中独立运行每个线程组时,线程组并行执行,如下,设置三个请求,每个线程组设置5秒启动5个线程. 未勾选独立运行 运行结果如下,三个线程并行执行 勾选后,一个线程组执行完后才执行下一 ...
- (001)每日SQL学习:关于UNION的使用
union内部必须有相同的列或者相同的数据类型,同时,每条 SELECT 语句中的列的顺序必须相同.union合并了select的结果集. union 与union all的不同: union合并了重 ...
- Routine Subroutine Coroutine 子程序 协程 子例程
https://en.wikipedia.org/wiki/Subroutine In computer programming, a subroutine is a sequence of prog ...
- Jenkins部署springboot项目
记录jenkins如何部署springboot项目(jar类型的) 一.首先需要先配置好jenkins的基本配置(jdk.maven--),可在系统管理-->>全局工具配置中进行配置. 配 ...
- 四. Ribbon负载均衡服务调用
1. 概述 1.1 Ribbon是什么 SpringCloud Ribbon是基于Netflix Ribbon实现的一套客户端,是负载均衡的工具. Ribbon是Netflix发布的开源项目,主要功能 ...
- layui的tabletree扩展组件
需求:点击父级菜单展示子级菜单 难点:某个父级菜单下面有5000条子级菜单(有点坑),当我想把这5000条子级菜单塞到父级菜单下面的时候完蛋了,页面卡死了... 解决:tabletree这组件我发现用 ...
- ByteDance 2019 春招题目
牛客网字节跳动笔试真题:https://www.nowcoder.com/test/16516564/summary 分了 2 次做,磕磕碰碰才写完,弱鸡悲鸣. 1. 聪明的编辑 题目:Link . ...
- python 文件的方法
1.open() 方法 Python open() 方法用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数,如果该文件无法被打开,会抛出 OSError. 注意:使用 open ...