题目链接: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. Java学习之线程通信(多线程(Lock))--生产者消费者

    SDK1.5版本以后对synchronized的升级,其思想是:将同步和锁封装成对象,其对象中包含操作锁的动作. 代码: //1.导入包 import java.util.concurrent.loc ...

  2. configure error C compiler cannot create executables错误解决

    我们在编译软件的时候,是不是经常遇到下面的错误信息呢?   checking build system type... i686-pc-linux-gnuchecking host system ty ...

  3. Java + selenium 元素定位(1)之By id/Name/ClassName

    这篇文章开始,要介绍web自动化核心的内容,也是最困难的部分了,就是定位元素,并去对元素进行操作.想要对元素进行操作,第一步,也是最重要的一步,就是要找到这个元素,如果连元素都定位不到,后续什么操作都 ...

  4. PHPStorm remoteHost链接FTP成功,但不显示文件目录

    ============================================== 勾上前两个选项就可以了

  5. python第一个问题

    temp=input("请输入1到100之间内的数字:")if num > 50:    print("你妹好漂亮")else:    print(&qu ...

  6. poj2752Seek the Name, Seek the Fame(next数组)

    题目传送门 Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2439 ...

  7. Quartz -----定时任务框架

    一.什么是Quartz     由java开发用来执行定时任务,类似于java.util.Timer.   但是相较于Timer,quartz增加了很多功能:                  持久性 ...

  8. UOJ197 线性规划

    传送门 由于这道题标程GG了所以必不可能AC嘛2333 单纯形法是一个很玄学的东西qwq 就是 非标准型 -> 标准型 -> 规范型 -> 松弛型 一个玄学操作——转轴操作(priv ...

  9. pycharm配色

    setting-appearanse-theme-IntelliJ setting-Editer-color scheme-Default setting-Editer-color scheme-py ...

  10. Cesium截图功能

    首先安装  canvas2image npm intsall canvas2image --save 因为项目基于vue,所以需要在canvas2image的最后面 加上 export default ...