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 ...
随机推荐
- gdb调试行号错位
http://blog.csdn.net/wangxmin2005/article/details/8128192 gdb调试过程中出现行号错位的情况,原因一般有两个: 1. 编译器的优化可能把某些语 ...
- elasticsearch 6.2.3安装ik分词
下载 zip文件 上传到服务器 https://github.com/medcl/elasticsearch-analysis-ik/releases unzip elasticsearch-anal ...
- 【bzoj1391】[Ceoi2008]order 网络流最小割
原文地址:http://www.cnblogs.com/GXZlegend/p/6796937.html 题目描述 有N个工作,M种机器,每种机器你可以租或者买过来. 每个工作包括若干道工序,每道工序 ...
- 【算法】最小乘积生成树 & 最小乘积匹配 (HNOI2014画框)
今天考试的时候果然题目太难于是我就放弃了……转而学习了一下最小乘积生成树. 最小乘积生成树定义: (摘自网上一篇博文). 我们主要解决的问题就是当k = 2时,如何获得最小的权值乘积.我们注意到一张图 ...
- [洛谷P4291][HAOI2008]排名系统
题目大意:三种操作: $+Name\;Socore:$上传最新得分记录,把以前的记录删除. $?Name:$ 查询玩家排名.如果两个玩家的得分相同,则先得到该得分的玩家排在前面. $?Index:$ ...
- ARC076 F Exhausted? Hall定理 + 线段树扫描线
---题面--- 题目大意: 有n个人,m个座位,每个人可以匹配的座位是[1, li] || [ri, m],可能有人不需要匹配座位(默认满足),问最少有多少人不能被满足. 题解: 首先可以看出这是一 ...
- Fragment里使用 PhoneGap 的 CordovaWebView
首先说明一下为什么要使用 CordovaWebView 而不直接使用 WebView 呢?由于 Android4.4 版本之后对 WebView 做了很大的改变,具体参考 这篇文章:理解WebKit和 ...
- jsp中的路径问题
在学jsp的时候我每次都遇到路径的问题,每次都不能够说100%的把这搞定,这让我很烦恼,今天下午花了点时间来把路径问题整理了下. 一:首先我们在加载项目(我的项目名称是FinalExam)是的路径是h ...
- Python基础(2)_if、for、while流程控制
一.流程控制 1.条件语句 1.1单分支 1.2多分支 条件判断 计算机之所以能做很多自动化的任务,因为它可以自己做条件判断. a = 5 if a > 2: print('yes') 根据Py ...
- mybatis基本流程、jdbc连接、ps:附mybatis(乐观锁)实现
一.前言 Mybatis和Hibernate一样,是一个优秀的持久层框架.已经说过很多次了,原生的jdbc操作存在大量的重复性代码(如注册驱动,创建连接,创建statement,结果集检测等).框架的 ...