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 ...
随机推荐
- 《单词的减法》state1~state17(200p)
单词的减法 2016.05.18 state 1 absent accessible accordingly accuracy/accurate acquaint/acquaintance adequ ...
- g++ 之 -m64选项
今天编译之前的项目,竟然报了下面的错误 usr/bin/ld: i386 architecture of input file `./proxycpp/soapRemoteDiscoveryBindi ...
- 斯坦福【概率与统计】课程笔记(三):EDA | 直方图
单个定量变量的直方图表示 大家知道,定量变量是连续型变量,即不会像分类变量那样有明显的分类,那么如何将其画成直方图呢?一般来说,会将其按照某个维度来将其分组(group),举个例子. 我们有15个学生 ...
- python学习笔记之数据类型、字符编码、文件处理
1.数据类型 1.数字(int,float) 整形(int):定义 age=20 #本质age=int(20) 浮点类型:salary=3000.3 #本质salary=float(3000.3) ...
- python 装饰器 对类和函数的装饰
#装饰器:对类或者函数进行功能的扩展 很多需要缩进的没有进行缩进'''#第一步:基本函数def laxi(): print('拉屎')#调用函数laxi()laxi() print('======= ...
- luoguP1080 国王游戏 题解(NOIP2012)(贪心+高精)
luoguP1080 国王游戏 题目 #include<iostream> #include<cstdlib> #include<cstdio> #include& ...
- linux ---pgbouncer的安装和配置
pgbouncer是一款轻量级针对postgresql的数据库连接工具,可以对客户端的连接做限制,防止恶意连接,另外也可以减少数据库的实际连接数,从而减少数据库的开销. 环境: centos 6.5 ...
- Ubuntu命令行操作
一.文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件) ls -a 列出当前目录文件(包括隐含文件) ls -l 列出当前目录下文件的详细信息 cd .. 回当前目录的上一级目录 cd - 回 ...
- CNN基础一:从头开始训练CNN进行图像分类(猫狗大战为例)
本文旨在总结一次从头开始训练CNN进行图像分类的完整过程(猫狗大战为例,使用Keras框架),免得经常遗忘.流程包括: 从Kaggle下载猫狗数据集: 利用python的os.shutil库,制作训练 ...
- CF963E Circles of Waiting
Circles of Waiting 求一个整点四连通随机游⾛,离原点距离超过R期望步数.R≤50. 带状矩阵法 本质上就是网格图的随机游走. \[ E_x=\sum_y P_{x,y}E_y+1 \ ...