C. Ancient Berland Circus(三点确定最小多边形)
题目链接:https://codeforces.com/problemset/problem/1/C
题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组成三角形。
思路:根据三角形三个顶点的坐标求得三角形的三边长a、b、c,海伦公式和正弦定理连理得半径R = abc / (4S),再求出外接圆圆心到三角形三个顶点组成的三个圆心角∠1、∠2、∠3的最大公约数作为正多边形的每一份三角形的内角,将所有三角形加起来即可。思路不难但是满满的细节orz,比如防止钝角的情况,边长最长的对应的圆心角 应该这样求: 2*PI - 其他两个圆心角。
AC代码:
- #include<bits/stdc++.h>
- using namespace std;
- const double eps = 1e-;
- const double pi = acos(-1.0);
- int sgn(double x)
- {
- if(fabs(x) < eps) return ;
- else return x < ? - : ;
- }
- double gcd(double a, double b)
- {
- if(sgn(b) == ) return a;
- if(sgn(a) == ) return b;
- return gcd(b, fmod(a,b));
- }
- struct Point{
- double x, y;
- void input(){
- scanf("%lf%lf", &x, &y);
- }
- double distant(Point p)
- {
- double a = (x - p.x);
- double b = (y - p.y);
- return sqrt(a * a + b * b);
- }
- };
- double angle(double a, double b, double c)
- {
- return acos((a * a + b * b - c * c)/(2.0 * a * b));
- }
- int main()
- {
- Point point[];
- for(int i = ;i < ;i++) point[i].input();
- double a = point[].distant(point[]);
- double b = point[].distant(point[]);
- double c = point[].distant(point[]);
- if(a > c) swap(a, c);
- if(b > c) swap(b, c);
- double p = (a + b + c) / 2.0;
- double S = sqrt(p*(p - a) * (p - b)* (p - c));
- double r = (a * b * c) /(4.0 * S);
- double A = angle(r, r, a);
- double B = angle(r, r, b);
- double C = * pi - A - B;
- double ave = gcd(A, gcd(B, C));
- double ans = r * r * sin(ave)* pi / ave;
- printf("%.8f\n",ans);
- return ;
- }
C. Ancient Berland Circus(三点确定最小多边形)的更多相关文章
- 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 #1 C. Ancient Berland Circus 计算几何
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...
- 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 ...
- Codeforces 1C Ancient Berland Circus
传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...
- codforces 1C Ancient Berland Circus(几何)
题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...
- 「CF1C Ancient Berland Circus」
CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^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 ...
- TZOJ 2392 Bounding box(正n边形三点求最小矩形覆盖面积)
描述 The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located ...
随机推荐
- POJ 1860 Currency Exchange (Bellman-Ford)
题目链接:POJ 1860 Description Several currency exchange points are working in our city. Let us suppose t ...
- 科普:std::sort干了什么
std::sort算是STL中对OIer比较友好的函数了,但你有想过sort是如何保证它的高速且稳定吗? 正文 我们首先来到第一层:sort函数 template<typename _Rando ...
- 组件化框架设计之Java SPI机制(三)
阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680 本篇文章将从深入理解java SPI机制来介绍组件化框架设计: ...
- Hibernate入门教程(二):Hibernate核心API
1.Configuraction onfiguration configuration = new Configuration(); configuration.configure(); 到src下面 ...
- luoguP3128 [USACO15DEC]最大流Max Flow 题解(树上差分)
链接一下题目:luoguP3128 [USACO15DEC]最大流Max Flow(树上差分板子题) 如果没有学过树上差分,抠这里(其实很简单的,真的):树上差分总结 学了树上差分,这道题就极其显然了 ...
- redis基础及基本命令
什么是redis Redis是一个Key-value存储系统,redis提供了丰富的数据结构,包括string(字符串),list(列表),sets(集合),ordered set(有序集合),has ...
- go语言从例子开始之Example10.map(字典)
map 是 Go 内置关联数据类型(在一些其他的语言中称为哈希 或者字典 ) package main import "fmt" func main() { 要创建一个空 map, ...
- pip飞起来了
这里说下Windows下的修改方法,看了网上很多的教程发现都不行,尝试了好久终于发现了可行的方法. 找到python安装目录下的:\Lib\site-packages\pip\models\index ...
- typedef 复杂函数指针
下面是三个变量的声明,我想使用typedef分别给它们定义一个别名,请问该如何做? >1:int *(*a[5])(int, char*); >2:void (*b[10]) (void ...
- linux软件包rpm的使用
一rpm包管理器 (一)rpm的介绍 rpm不仅是文件的后缀,也是一个工具,外部命令,程序包管理器 功能:将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装.卸载. ...