题目链接:https://codeforces.com/problemset/problem/1/C

题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组成三角形。

思路:根据三角形三个顶点的坐标求得三角形的三边长a、b、c,海伦公式和正弦定理连理得半径R = abc / (4S),再求出外接圆圆心到三角形三个顶点组成的三个圆心角∠1、∠2、∠3的最大公约数作为正多边形的每一份三角形的内角,将所有三角形加起来即可。思路不难但是满满的细节orz,比如防止钝角的情况,边长最长的对应的圆心角 应该这样求: 2*PI - 其他两个圆心角。

AC代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const double eps = 1e-;
  4. const double pi = acos(-1.0);
  5. int sgn(double x)
  6. {
  7. if(fabs(x) < eps) return ;
  8. else return x < ? - : ;
  9. }
  10. double gcd(double a, double b)
  11. {
  12. if(sgn(b) == ) return a;
  13. if(sgn(a) == ) return b;
  14. return gcd(b, fmod(a,b));
  15. }
  16. struct Point{
  17. double x, y;
  18. void input(){
  19. scanf("%lf%lf", &x, &y);
  20. }
  21. double distant(Point p)
  22. {
  23. double a = (x - p.x);
  24. double b = (y - p.y);
  25. return sqrt(a * a + b * b);
  26. }
  27. };
  28. double angle(double a, double b, double c)
  29. {
  30. return acos((a * a + b * b - c * c)/(2.0 * a * b));
  31. }
  32.  
  33. int main()
  34. {
  35. Point point[];
  36. for(int i = ;i < ;i++) point[i].input();
  37. double a = point[].distant(point[]);
  38. double b = point[].distant(point[]);
  39. double c = point[].distant(point[]);
  40. if(a > c) swap(a, c);
  41. if(b > c) swap(b, c);
  42. double p = (a + b + c) / 2.0;
  43. double S = sqrt(p*(p - a) * (p - b)* (p - c));
  44. double r = (a * b * c) /(4.0 * S);
  45. double A = angle(r, r, a);
  46. double B = angle(r, r, b);
  47. double C = * pi - A - B;
  48. double ave = gcd(A, gcd(B, C));
  49. double ans = r * r * sin(ave)* pi / ave;
  50. printf("%.8f\n",ans);
  51. return ;
  52. }

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. POJ 1860 Currency Exchange (Bellman-Ford)

    题目链接:POJ 1860 Description Several currency exchange points are working in our city. Let us suppose t ...

  2. 科普:std::sort干了什么

    std::sort算是STL中对OIer比较友好的函数了,但你有想过sort是如何保证它的高速且稳定吗? 正文 我们首先来到第一层:sort函数 template<typename _Rando ...

  3. 组件化框架设计之Java SPI机制(三)

    阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680 本篇文章将从深入理解java SPI机制来介绍组件化框架设计: ...

  4. Hibernate入门教程(二):Hibernate核心API

    1.Configuraction onfiguration configuration = new Configuration(); configuration.configure(); 到src下面 ...

  5. luoguP3128 [USACO15DEC]最大流Max Flow 题解(树上差分)

    链接一下题目:luoguP3128 [USACO15DEC]最大流Max Flow(树上差分板子题) 如果没有学过树上差分,抠这里(其实很简单的,真的):树上差分总结 学了树上差分,这道题就极其显然了 ...

  6. redis基础及基本命令

    什么是redis Redis是一个Key-value存储系统,redis提供了丰富的数据结构,包括string(字符串),list(列表),sets(集合),ordered set(有序集合),has ...

  7. go语言从例子开始之Example10.map(字典)

    map 是 Go 内置关联数据类型(在一些其他的语言中称为哈希 或者字典 ) package main import "fmt" func main() { 要创建一个空 map, ...

  8. pip飞起来了

    这里说下Windows下的修改方法,看了网上很多的教程发现都不行,尝试了好久终于发现了可行的方法. 找到python安装目录下的:\Lib\site-packages\pip\models\index ...

  9. typedef 复杂函数指针

    下面是三个变量的声明,我想使用typedef分别给它们定义一个别名,请问该如何做? >1:int *(*a[5])(int, char*); >2:void (*b[10]) (void ...

  10. linux软件包rpm的使用

    一rpm包管理器 (一)rpm的介绍 rpm不仅是文件的后缀,也是一个工具,外部命令,程序包管理器 功能:将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装.卸载. ...