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 ...
随机推荐
- sqlite sql语句关键字GROUP BY的理解
第一遍看GROUP BY的介绍时,没看懂. SQLite 的 GROUP BY 子句用于与 SELECT 语句一起使用,来对相同的数据进行分组.在 SELECT 语句中,GROUP BY 子句放在 W ...
- web相关基础知识1
2017-12-13 09:47:11 关于HTML 1.绝对路径和相对路径 相对路径:相对于文件自身为参考. (工作中一般是使用相对路径) 这里我们用html文件为参考.如果说html和图片平级,那 ...
- REST接口设计规范
URI格式规范 URI(Uniform Resource Identifiers) 统一资源标示符 URL(Uniform Resource Locator) 统一资源定位符 URI的格式定义如下: ...
- 列数不固定时怎么使用el-tabel展示数据
<el-table :data="contents" stripe> <el-table-column v-for="(item, index) in ...
- ELK + Kafka + Filebeat
ELK + Kafka + Filebeat学习 https://blog.csdn.net/qq_21383435/article/details/79463832 https://blog.csd ...
- 日期时间选择器datetimepicker.js
在做项目中,往往会遇到需要用户输入2014-07-19 09:55:53这样的格式的数据.就是典型的年月日时分秒这样的格式.这个时候,使用datetimepicker会比较简单. DateTimePi ...
- Codeforces Round #390 (Div. 2) E(bitset优化)
题意就是一个给出2个字符矩阵,然后进行匹配,输出每个位置的匹配的结果 (超出的部分循环处理) 一种做法是使用fft,比较难写,所以没有写 这里使用一个暴力的做法,考虑到一共只出现26个字符 所以使用一 ...
- 利用FFT来进行字符串匹配
给定串A和串B,A由26个小写字母构成,B由?和26个小写字母构成 ?可以和任意字符匹配 求A中出现了多少次B 这里可以使用fft做法,定义向量A和向量B 然后求A和rev(B)的卷积结果C C的第i ...
- [bzoj1056] [HAOI2008]排名系统
Description 排名系统通常要应付三种请求:上传一条新的得分记录.查询某个玩家的当前排名以及返回某个区段内的排名记录.当某个玩家上传自己最新的得分记录时,他原有的得分记录会被删除.为了减轻服务 ...
- BZOJ_day???
哇哈哈哈哈,这周能不能保持这个呢?