AC日记——codeforces Ancient Berland Circus 1c
思路:
求出三角形外接圆;
然后找出三角形三条边在小数意义下的最大公约数;
然后n=pi*2/fgcd;
求出面积即可;
代码:
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define INF (1e9)
#define eps (1e-4)
#define pi (3.1415926535) struct point
{
double x,y;
};
struct point ai[]; struct line {
double k,b; line *another; void updata(struct point a,struct point bb)
{
another=new line;
if(a.x==bb.x) k=INF,b=a.x;
else
{
if(a.y==bb.y) k=,b=a.y;
else
{
k=(bb.y-a.y)/(bb.x-a.x);
b=a.y-k*a.x;
}
}
if(k==)
{
another->k=INF,another->b=(a.x+bb.x)/2.0;
}
else if(k==INF)
{
another->k=,another->b=(a.y+bb.y)/2.0;
}
else
{
another->k=-1.0/k;
struct point temp;
temp.x=(a.x+bb.x)/2.0;
temp.y=(a.y+bb.y)/2.0;
another->b=temp.y-another->k*temp.x;
}
}
};
struct line bi[],ci[]; struct point getnode(line a,line b)
{
struct point res;
res.x=(b.b-a.b)/(a.k-b.k);
res.y=a.k*res.x+a.b;
return res;
} double dist(struct point a,struct point b)
{
double aa=(a.x-b.x)*(a.x-b.x);
double bb=(a.y-b.y)*(a.y-b.y);
aa=sqrt(aa+bb);
return aa;
} double fgcd(double x, double y) {
while (fabs(x)>eps&&fabs(y)>eps)
{
if (x > y) x-=floor(x/y)*y;
else y-=floor(y/x)*x;
}
return x + y;
} int main()
{
for(int i=;i<=;i++) cin>>ai[i].x>>ai[i].y;
bi[].updata(ai[],ai[]);
bi[].updata(ai[],ai[]);
bi[].updata(ai[],ai[]);
for(int i=;i<=;i++) ci[i]=*bi[i].another;
struct point o=getnode(ci[],ci[]);
double R=dist(o,ai[]);
double vi[];
vi[]=dist(ai[],ai[]);
vi[]=dist(ai[],ai[]);
vi[]=dist(ai[],ai[]);
sort(vi+,vi+);
double an[];
an[]=2.0*asin(vi[]/(2.0*R));
an[]=2.0*asin(vi[]/(2.0*R));
an[]=2.0*pi-an[]-an[];
sort(an+,an+);
double ans1=fgcd(an[],an[]);
double ans2=fgcd(an[],an[]);
double ans=fgcd(max(ans1,ans2),min(ans1,ans2));
double ans_=(2.0*pi-ans)/2.0;
printf("%.9lf",R*R*sin(ans)*pi/ans);
return ;
}
AC日记——codeforces Ancient Berland Circus 1c的更多相关文章
- Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...
- 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 ...
- CodeForces - 1C:Ancient Berland Circus (几何)
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things ...
- Codeforces 1C Ancient Berland Circus
传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...
- codforces 1C Ancient Berland Circus(几何)
题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...
- C. Ancient Berland Circus(三点确定最小多边形)
题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组 ...
- 「CF1C Ancient Berland Circus」
CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...
- 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 ...
- CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...
随机推荐
- [C/C++] C++中new的语法规则
int *x = new int; //开辟一个存放整数的存储空间,返回一个指向该存储空间的地址(即指针) ); //开辟一个存放整数的空间,并指定该整数的初值为100,返回一个指向该存储空间的地址 ...
- hdu 1133 Buy the Ticket (大数+递推)
Buy the Ticket Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- timeSetEvent()函数
原文链接地址:http://www.cnblogs.com/kangwang1988/archive/2010/09/16/1827872.html 微软公司在其多媒体Windows中提供了精确定时器 ...
- [Leetcode] Remove duplicates from sorted array 从已排序的数组中删除重复元素
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- NEYC 2017 自动取款机 atm Day6 T1
自动取款机 [问题描述] 小 ...
- HDU4185:Oil Skimming(二分图最大匹配)
Oil Skimming Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- 1、linux下mysql5.5.20安装过程报错汇总
1.Access denied for user 'root'@'localhost' (using password: YES) 这个提示是因为root帐户默认不开放远程访问权限,所以需要修改一下相 ...
- 转:Nginx国人开发缩略图模块(ngx_image_thumb)
ngx_image_thumb是nginx中用来生成缩略图的模块,生存缩略图的方法很多,之前也写过一篇 <nginx生成缩略图配置>,在github上发现国人开发的一款模块,作者的文档写的 ...
- Ueditor 1.4.3 插入表格后无边框无颜色,不能正常显示
在使用Ueditor 插入表格的功能时,发现插入时正常. 但保存到后台后再取出来,表格不能正常显示.查看保存的html代码,发现保存时并未给table 添加border属性.以致于再次取出来时,不能正 ...
- 403 Forbidden 错误
Forbidden You don't have permission to access /a.php on this server. apache昨天调试 httpd.conf 文件:<Di ...