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. react+propTypes

    React.createClass({ propTypes: { // 可以声明 prop 为指定的 JS 基本数据类型,默认情况,这些数据是可选的 optionalArray: React.Prop ...

  2. 问题03.如果有多个集合的迭代处理情况【使用MAP】

    在SQL开发过程中,动态构建In集合条件查询是比较常见的用法,在Mybatis中提供了foreach功能,该功能比较强大,它允许你指定一个集合,声明集合项和索引变量,它们可以用在元素体内.它也允许你指 ...

  3. JS学习之函数的属性和方法

  4. 【JAVA】Pattern和Matcher

    ZZ: Java正则表达式:Pattern类和Matcher类 一.捕获组的概念 捕获组可以通过从左到右计算其开括号来编号,编号是从1 开始的.例如,在表达式 ((A)(B(C)))中,存在四个这样的 ...

  5. 东方14ACM小组 Challenge 11

    总时间限制:  10000ms 单个测试点时间限制:  1000ms 内存限制:  262144kB 描述 给一个长为N的数列,有M次操作,每次操作是以下两种之一: (1)修改数列中的一个数 (2)求 ...

  6. 【bzoj3376-方块游戏】带权并查集

    题意: n块积木,m个操作或询问.每次移动积木的时候,约翰会选择两块积木X,Y,把X搬到Y的上方.如果X已经和其它积木叠在一起了,那么应将这叠积木整体移动到Y的上方:如果Y已经和其它积木叠在一起了的, ...

  7. Quick-Cocos2dx-Community_3.6.3_Release 编译时libtiff.lib 无法解析

    Quick-Cocos2dx-Community_3.6.3_Release 使用VS2012编译,报错: libtiff.lib lnk2001 无法解析的外部符号 ltod3 类似于上面这种,刚才 ...

  8. Dungeon Master(三维bfs)

    题目链接:http://poj.org/problem?id=2251 题目: Description You are trapped in a 3D dungeon and need to find ...

  9. MySQL 8.0 正式版 8.0.11 发布:比 MySQL 5.7 快 2 倍

    ySQL 8.0 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 MySQL 5.7 快 2 倍,还带来了大量的改进和更快的性能! 注意:从 MySQL 5.7 升级到 MySQL 8. ...

  10. Centos7编译安装Xen环境(vtpm)

    编译xen环境(http://www.lvtao.net/server/574.html#comment-1882): yum update yum groupinstall "Develo ...