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 ...
随机推荐
- Kali开启SSH服务
1. 一.配置SSH参数 修改sshd_config文件,命令为: vi /etc/ssh/sshd_config 将#PasswordAuthentication no的注释去掉,并且将NO修 ...
- 如何为元组中的每个元素命名,提高程序可读性---Python数据结构与算法相关问题与解决技巧
实际案例: 学生信息系统中,数据为固定格式:(名字,年龄,性别,邮箱) ,通常使用元组来存储 使用优点: 使用元组最大的优点在于节省空间,存储相同的数据,使用元组比使用字典,空间小很多 使用缺点: 访 ...
- http常见7种请求
抛砖引玉,聊下概念性的东西先: HTTP协议 (Hyper Text Transfer Protocol) HTTP是一个基于TCP/IP通信协议来传递数据,包括html文件.图像.结果等,即是一个客 ...
- ---搭建springMvc框架,希望对初学者有所参考
Spring Mvc ==> Struts2 spring 无法替代 myBatis 工作量大 要自己操作sql语句 ==> hibernate Spring Mvc 取代St ...
- spring注解开发:容器中注册组件方式
1.包扫描+组件标注注解 使用到的注解如下,主要针对自己写的类 @Controller @Service @Repository @Component @ComponentScan 参考 spring ...
- C#反射的实现
一,什么是反射? 1,System.Reflection 命名空间中的类与 System.Type 使你能够获取有关加载的程序集和其中定义的类型的信息,如类.接口和值类型. 可以使用反射在运行时创建. ...
- etcd注册服务
etcd作为最简单(轻量,精简)的kv服务.etcd可以应用很多方面,但是它有一个特点,etcd只是基础,需要你自己实现功能.它不像其其它组件开箱即用,也正是如此,它足够简单精巧. 回到主题,etcd ...
- 将循环结果通过管道传递给其他命令处理(done |)
- 使用intellij的idea集成开发工具中的git插件(转)
转自:https://blog.csdn.net/u012225679/article/details/71123171 注意:这里并没有介绍git客户端的安装,如果要安装客户端,大家可以参考如下的链 ...
- mongodb C#连接报错 Invalid credentials for database 'admin'
这2天学习mongodb3.2.9,用户设置好了,结果用C#查询的时候报错了,看字面意思是用户验证没通过,但是我用shell是完全没有问题的,后来网上搜了下,发现原来是我用的是旧驱动,旧驱动用的是旧的 ...