题目链接: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(三点确定最小多边形)的更多相关文章

  1. 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 ...

  2. Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何

    C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...

  3. AC日记——codeforces Ancient Berland Circus 1c

    1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #includ ...

  4. CodeForces - 1C:Ancient Berland Circus (几何)

    Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things ...

  5. Codeforces 1C Ancient Berland Circus

    传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...

  6. codforces 1C Ancient Berland Circus(几何)

    题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...

  7. 「CF1C Ancient Berland Circus」

    CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...

  8. 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 ...

  9. TZOJ 2392 Bounding box(正n边形三点求最小矩形覆盖面积)

    描述 The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located ...

随机推荐

  1. 建议66,67 注意Arrays.asList()的使用

    代码 public static void main(String[] args) { int[]data = {1,2,3,4,5}; List list = Arrays.asList(data) ...

  2. JavaScript的日期对象

    1.Date对象用来处理日期和时间. 2.创建Date对象的语法: var myDate = new Date(); 3.Date对象的常用方法: 格式:Date.XX(); getDate() 从 ...

  3. c# WInform 自定义导航布局

    问题形成原因:软件一般都是左侧树导航或上部菜单导航,做好一个软件后,有的客户可能想用一个页面做导航图像,而各个客户用的功能可能不同,所以导航布局需要自定义. 思路:1.把菜单列出来 2.双击菜单生成一 ...

  4. 修改默认runlevel

    CentOS直接修改文件  /etc/inittab 就好了 # Default runlevel. The runlevels used are: # - halt (Do NOT set init ...

  5. hashRouter and BrowserRouter

    <html><body> <div> <button class="btn" onclick="btnFun();"& ...

  6. shell位置参数的遍历

  7. while/until/for 循环举例2

  8. python数字图像处理(一)图像的常见操作

    首先导入必要的库,使用Opencv读入图像,避免复杂的图像解析,同时使用Opencv作为算法的对比,由于使用环境为jupyter使用matplotlib直接可视化 import cv2 import ...

  9. servlet 实践

    基础 当Servlet引擎收到一个请求,它将请求所有的细节汇编到一个HttpServletRequest对象.细节包括请求头部.URI.查询字符串和任意发送的参数等等.类似地,它初始化一个处理响应头部 ...

  10. Codeigniter项目使用phpDocumentor生成api文档

    前言 运行环境: vagrant 2.2.4 virtualbox 6.0 box bento/ubuntu-16.04 (Apache 2.4.18 + Mysql 5.7.26 + PHP 5.6 ...