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. Git版本管理1-安装配置和同步

    原文载于youdaonote,有图片: http://note.youdao.com/share/?id=79a2d4cae937a97785bda7b93cbfc489&type=note ...

  2. hibernate 如何配置两个属性唯一

    在单一字段的唯一性约束时,我们可以在映射文件里配置property属性的unique="true"来达到目的,但多字段的唯一性约束怎样处理呢?如 果使用复合主键可以很简单地解决这个 ...

  3. rename 批量重命名

    使用背景,对规则文件名批量重命名 例如: Send_Message_20160802_01_log.log Send_Message_20160802_02_log.log Send_Message_ ...

  4. String作为输出型参数时获取不到值

    有时候在一个方法中,我们需要返回多个字符串,而又不想将这些字段包成一个类.此时就需要使用输出型参数. 但是如果将输出型参数的类型声明为String,那么调用该方法后,是获取不到我们想要的值的. 测试代 ...

  5. MySql 利用函数 查询所有子节点

    前提:mysql  函数  find_in_set(str,strlist), cast(value as type)   一.find_in_set(str,strlist):如果字符串str是在的 ...

  6. vijos 1426 背包+hash

    背景 北京奥运会开幕了,这是中国人的骄傲和自豪,中国健儿在运动场上已经创造了一个又一个辉煌,super pig也不例外……………… 描述 虽然兴奋剂是奥运会及其他重要比赛的禁药,是禁止服用的.但是运动 ...

  7. 前端表单序列化为json串,以及构造json数组、json串

    var parm={ username:"zhangsan", age:24, email:"352400260@qq.com" }; console.log( ...

  8. Android项目分包---总结-------直接使用

    注: 本文是从该文摘抄而来的.简单的说,就是阅读了该文,然后,再自己复述,复制形成该文.   1.罗列Android项目的分包规则   微盘使用分包规则   如下:     1).第一层com.sin ...

  9. bzoj 1594: [Usaco2008 Jan]猜数游戏——二分+线段树

    Description 为了提高自己低得可怜的智商,奶牛们设计了一个新的猜数游戏,来锻炼她们的逻辑推理能力. 游戏开始前,一头指定的奶牛会在牛棚后面摆N(1 <= N<= 1,000,00 ...

  10. idea 导入 java json 包

    1.java 项目导包 找到 External Libraries 下面的java版本包,在点击鼠标右键.直接找到jar路径全部选中导入即可.