题意

给出正多边形上三个点的坐标,求正多边形的最小面积

分析

先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应的三角形的面积

注意如果三个点在同一段半圆弧上,需要thec=2*pi-thea-theb,而不能直接用acos()函数求

数据卡精度,gcd要取0.001才行,其他不行

#include <bits/stdc++.h>
using namespace std; #define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))
const double pi = acos(-1.0);
double x1,x2,x3,y1,y2,y3;
double calc(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double work(double r,double x)
{
return (r*r*2-x*x)/(2*r*r);
}
double cal(double a,double b)
{
while(a-b>=-0.001) a-=b;return a;
}
double gcd(double a,double b)
{
if(b<=0.001) return a;
else return gcd(b,cal(a,b));
}
bool feq (double a, double b) {
return fabs(a-b) < 0.0001;
} double fgcd(double a, double b) {
if (feq(a, 0)) return b;
if (feq(b, 0)) return a;
return fgcd(b, fmod(a, b));
}
int main()
{
cin>>x1>>y1>>x2>>y2>>x3>>y3;
double a=calc(x1,y1,x2,y2),b=calc(x1,y1,x3,y3),c=calc(x2,y2,x3,y3);
//printf("a=%f b=%f c=%f\n",a,b,c );
double p=(a+b+c)/2,S=sqrt(p*(p-a)*(p-b)*(p-c)),r=a*b*c/(4*S);
double cosa=work(r,a),cosb=work(r,b),cosc=work(r,c);
//printf("%f %f %f\n",cosa,cosb,cosc );
double thea=acos(cosa),theb=acos(cosb),thec=2*pi-thea-theb;//注意
//printf("%f %f %f\n", thea/(2*pi)*180,theb/(2*pi)*180,thec/(2*pi)*180);
double jiao=gcd(thea,gcd(theb,thec));
//printf("jiao=%f cnt=%f sin==%f\n",jiao/(2*pi)*180,cnt,sinn);
double ans=r*r*sin(jiao)/2*2*pi/jiao;
printf("%.6f\n", ans);
return 0;
}

codforces 1C 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 1C Ancient Berland Circus

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

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

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

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

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

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

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

  6. C. Ancient Berland Circus(三点确定最小多边形)

    题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组 ...

  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. CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列

    B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...

随机推荐

  1. 【转载】.NET Remoting学习笔记(三)信道

    目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道 参考:♂风车车.Net .NET Framework ...

  2. 解决编译twrp3.0.3遇到的问题

    1. 问题: ninja: error: '/home/jessie/OMNI/out/target/product/m1/obj/SHARED_LIBRARIES/libcryptfs_hw_int ...

  3. Animated progress view with CAGradientLayer(带翻译)

    Animated progress view with CAGradientLayer(带翻译)  Modern software design is getting flatter and thin ...

  4. Centos6.5 安装 Oracle11gR2(64位)

    Centos6.5安装 Oracle11gR2(64位) 安装centos6.5 (我的是虚拟机环境) 1.  下载centos6.5的安装包,不解释. 例如以下图: 2.  下载oracle安装包, ...

  5. vue 单页面(SPA) history模式调用微信jssdk 跳转后偶尔 "invalid signature"错误解决方案

    项目背景 vue-cli生成的单页面项目,router使用history模式.产品会在公众号内使用,需要添加微信JSSDK,做分享相关配置. 遇到的问题 相关配置与JS接口安全域名都已经ok,发布后, ...

  6. sanic官方文档解析之logging和request Data

    1,sanic的logging: Sanic允许有做不同类型的日志(通过的日志,错误的日志),在基于Python3的日志API接口请求,你必须具备基本的Python3的日志知识,在你如果想创建一个新的 ...

  7. 4.改变eclipse选中文字颜色

    window-preferences-general-editors-text editors-annotations-occurrences 和 window-preferences-general ...

  8. MySQL的简单优化

    一.如何发现需要优化的SQL 主要使用MySQL的慢查日志对有效率问题的SQL进行监控 第一步:启动慢查日志的监控 打开开关,将未使用索引的查询记录到慢查日志中 设置查询时间,当查询时间大于这个值,就 ...

  9. ios状态栏的一些操作

    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; //显示 [UIApplication sharedA ...

  10. NEU 1681: The Singles

    题目描述 The Signals’ Day has passed for a few days. Numerous sales promotion campaigns on the shopping ...