C. Ancient Berland Circus
time limit per test

2 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

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

In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.

Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.

You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.

Input

The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.

Output

Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.

Examples
input

Copy
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
output

Copy
1.00000000

几何数学题,写这个题完全就是记忆一下数学公式。。。

题意就是给你一个正多边形三个点的坐标,三点一定能构成三角形,通过这三个点求所在的多边形的最小面积,肯定是边越少面积越小。

通过三点坐标可以求出三角形的三边长a,b,c;然后求出三角形的面积,然后求出圆的半径。

然后求出三个角(不是三角形的三个角,是圆心对应的三个角),首先算出余弦,cosC=(a*a+b*b-c*c)/(2*a*b);就是cosC=(r*r+r*r-c*c)/(2*r*r);

然后反余弦函数arccos,代码就是acos(cosC),求出角度C。

求出来三个角之后,找三个角的最大公约数,然后求出这最大公约数的三角形对应的三角形的面积,然后总的圆心角2*PI/最大公约数,就是一共的个数,乘起来就可以了。

三角形的面积:海伦公式 s=sqrt(p*(p-a)*(p-b)*(p-c)),p=(a+b+c)/2;

又因为三角形面积s=1/2*a*b*sinC.

因为a/sinA=b/sinB=c/sinC=2*r,所以sinC=c/(2*r),所以s=a*b*c/(4*r).

好多啊,不想写了。。。直接贴一下别人的题解。

传送门:

CodeForces-1C-Ancient Berland Circus

这个题eps开的太小会错,一开始写的1e-9,wa了,改成1e-4过了,精确度太高过不了。。。

代码:

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
const double PI=acos(-1.0);
const double eps=1e-; struct node{
double x,y;
}; double len(node a,node b)//求边长
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
} double acos(double a,double b,double c)//求反余弦
{
return acos((a*a+b*b-c*c)/(*a*b));
} double fgcd(double a,double b)//求浮点数的gcd
{
if(b<eps) return a;
return fgcd(b,fmod(a,b));
} int main()
{
node A,B,C;
cin>>A.x>>A.y;cin>>B.x>>B.y;cin>>C.x>>C.y;
double a=len(B,C),b=len(A,C),c=len(A,B);
//cout<<a<<" "<<b<<" "<<c<<endl;
double p=(a+b+c)/;
double s=sqrt(p*(p-a)*(p-b)*(p-c));//海伦公式求三角形面积
double r=a*b*c/(*s);//求圆的半径
double AA=acos(r,r,a),BB=acos(r,r,b),CC=*PI-AA-BB;//求角度
//cout<<AA<<" "<<BB<<" "<<CC<<endl;
double angle=fgcd(AA,fgcd(BB,CC));//求最大公约数的角度
//cout<<angle<<endl;
double sr=(r*r*sin(angle))/;//求每一小块的面积
double ans=sr**PI/angle;
printf("%.6f\n",ans);
}

Codeforces 1 C. Ancient Berland Circus-几何数学题+浮点数求gcd ( Codeforces Beta Round #1)的更多相关文章

  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 (几何)

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

  3. codforces 1C Ancient Berland Circus(几何)

    题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...

  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. AC日记——codeforces Ancient Berland Circus 1c

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

  6. CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列

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

  7. Codeforces 1C Ancient Berland Circus

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

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

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

  9. 「CF1C Ancient Berland Circus」

    CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...

随机推荐

  1. echarts.js中的图表大小自适应

    echarts的图表,如果父级容器的height/width属性设置为百分比的形式,那么echarts就会warning,且不能正常的生成图表.所以div容器的高度宽度必须指定为px,这设计不知道是为 ...

  2. a标签nest问题,即a标签里面嵌套a标签

    方法一:使用div模拟a,监听click事件 方法二:使用<object>标签包裹内部a标签 <div style="width: 200px;height: 200px; ...

  3. [LeetCode] 数组的最长连续数, O(n)解法

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

  4. 小程序var that=this

    小程序的js函数中,一般第一句就是var that=this,那么此语句的必要性是什么呢?下面用一段代码来解释这个问题 Page({ //页面的初始数据 loadUsers: function () ...

  5. bzoj 2258 splay

    类似于1014,用splay维护这个序列,维护每个节点为根的子树的hash值,对于一个询问二分答案判断就行了. 反思:询问的时候因为是原序列的x,y,所以开始的时候直接splay(x-1)了,后来发现 ...

  6. Vue 定义组件模板的七种方式(一般用单文件组件更好)

    在 Vue 中定义一个组件模板,至少有七种不同的方式(或许还有其它我不知道的方式): 字符串 模板字面量 x-template 内联模板 render 函数 JSF 单文件组件 在这篇文章中,我将通过 ...

  7. 加overflow-hidden就可以解决高度塌陷问题,overflow-触发BFC

    1.BFC 全称是块级排版上下文,用于对块级元素排版,默认情况下只有根元素(body)一个块级上下文,但是如果一个块级元素 设置了float:left,overflow:hidden或position ...

  8. Codeforces Round #483 (Div. 1) 简要题解

    来自FallDream的博客,未经允许,请勿转载,谢谢. 为了证明一下我又来更新了,写一篇简要的题解吧. 这场比赛好像有点神奇,E题莫名是道原题,导致有很多选手直接过掉了(Claris 表演24s过题 ...

  9. shellcheck 帮助你写出更好的脚本

    简介 shellcheck 是一款实用的 shell脚本静态检查工具. 首先,可以帮助你提前发现并修复简单的语法错误,节约时间.每次都需要运行才发现写错了一个小地方,确实非常浪费时间. 其次,可以针对 ...

  10. MACHINE_START与MACHINE_END【转】

    转自:http://blog.csdn.net/cxw3506/article/details/8475965 版权声明:本文为博主原创文章,未经博主允许不得转载. 在移植Linux时,有个结构体需要 ...