要点

  • 各点肯定都在外接圆上,边越多越接近圆面积,所以要最小面积应当取可能的最少边数。
  • 给三角形求外接圆半径公式:\(R=\frac{abc}{4S}\)。
  • 三个角度对应的圆心角取gcd即是要求的正多边形的一个角度,然后求面积即可。注意三个圆心角的求法是三个内角乘2.
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std; typedef double db;
const db PI = acos(-1.0);
const db eps = 1e-2; db x[3], y[3], len[3]; db sqr(db x) {
return x * x;
} db S(db a, db b, db c) {
db p = (a + b + c) / 2;
db res = p * (p - a) * (p - b) * (p - c);
return sqrt(res);
} db calc(db c, db a, db b) {
db res = (sqr(a) + sqr(b) - sqr(c)) / 2 / a / b;
return acos(res + 1e-8);
} db gcd(db a, db b) {
if (fabs(b) < eps) return a;
return gcd(b, fmod(a, b));
} int main() {
for (int i = 0; i < 3; i++)
scanf("%lf%lf", &x[i], &y[i]); db mul = 1.0;
for (int i = 0; i < 3; i++) {
int j = (i + 1) % 3;
len[i] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
mul *= len[i];
} db R = mul / 4 / S(len[0], len[1], len[2]);
db delta = -1, select;
for (int i = 0; i < 3; i++) {
db tmp = calc(len[i], len[(i + 1) % 3], len[(i + 2) % 3]);
tmp *= 2;
if (delta < 0) delta = tmp;
else delta = gcd(tmp, delta);
}
db ans = sqr(R) * sin(delta) * PI / delta;
return !printf("%.20lf\n", ans);
}

Codeforces 1C(外接圆与正多边形)的更多相关文章

  1. Codeforces 1C Ancient Berland Circus

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

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

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

  3. codeforces 1C (非原创)

    C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...

  4. codeforces1C

    Ancient Berland Circus CodeForces - 1C 如今,Berland 的所有马戏表演都有一个圆形的竞技场,其直径为 13 米,但过去的情况有所不同. 在古代 Berlan ...

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

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

  6. Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举

    https://codeforces.com/contest/1096/problem/C 题意 问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数 题解 三点构成的角是个圆周角,假设 ...

  7. HDU4195 Regular Convex Polygon (正多边形、外接圆)

    题意: 给你正n边形上的三个点,问n最少为多少 思路: 三个点在多边形上,所以三个点的外接圆就是这个正多边形的外接圆,余弦定理求出每个角的弧度值,即该角所对边的圆周角,该边对应的圆心角为圆心角的二倍. ...

  8. Codeforces Round #604 (Div. 1) - 1C - Beautiful Mirrors with queries

    题意 给出排成一列的 \(n\) 个格子,你要从 \(1\) 号格子走到 \(n\) 号格子之后(相当于 \(n+1\) 号格子),一旦你走到 \(i+1\) 号格子,游戏结束. 当你在 \(i\) ...

  9. 计算正多边形的面积 Gym - 101840G

    http://codeforces.com/gym/101840/attachments 题目大意:输入n,r,k .n代表往外扩张几次,r代表圆的内接圆半径,k代表多边形的边长.问你每次扩张多边形和 ...

随机推荐

  1. 系统常用VC++运行时下载地址

    Microsoft Visual C++ 2005 Microsoft Visual C++ 2005 Redistributable Package (x86)  https://www.micro ...

  2. PSPnet:Pyramid Scene Parsing Network——作者认为现有模型由于没有引入足够的上下文信息及不同感受野下的全局信息而存在分割出现错误的情景,于是,提出了使用global-scence-level的信息的pspnet

    from:https://blog.csdn.net/bea_tree/article/details/56678560 2017年02月23日 19:28:25 阅读数:6094 首先声明,文末彩蛋 ...

  3. Go丨语言对数据库操作报错 panic: dial tcp 127.0.0.1:3306: connectex: No connection could be made because the target machine actively refused it.

    panic: dial tcp 127.0.0.1:3306: connectex: No connection could be made because the target machine ac ...

  4. animation-delay负值

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. storm--chuanzhiboke

    Storm里面有7种类型的stream grouping 1. Shuffle Grouping: 随机分组, 随机派发stream里面的tuple,保证每个bolt接收到的tuple数目大致相同. ...

  6. 批处理中格式化Date

    @Echo Off Set _Date=%date% If "%_Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _Nu ...

  7. UML统一建模语UML2和EnterpriseArchitect

    其实前面的UML统一建模语言(一)所描述的都是UML1的内容,现在咱们聊一聊UML2. UML2.x完全建立在UML1.x基础之上,大多数的UML1.x模型在UML2.x中都可用.但UML2.x在结构 ...

  8. SpringMVC之七:SpringMVC中使用Interceptor拦截器

    SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那 ...

  9. jquery中对于批量deferred的处理

    此代码仿照jquery源码中$.when()的实现 function test(i) { var dfd = $.Deferred(); if(i%2 == 0) { console.log(&quo ...

  10. java枚举类型的优势在哪里?--一个实例

    最近在做一个项目,其中涉及到一组操作,命名为: 1. "add"; 2. "logicDel" 3. "physicDel" 4. &quo ...