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. Linux(CentOS6.7) 安装MySql5.7数据库 图文教程

    linux(CentOS6.7) 环境Mysql 5.7.17安装教程分享给大家,供大家参考,具体内容如下: 1系统约定安装文件下载目录:/data/softwareMysql目录安装位置:/usr/ ...

  2. 常见的Shell

    上面提到过,Shell是一种脚本语言,那么,就必须有解释器来执行这些脚本. Unix/Linux上常见的Shell脚本解释器有bash.sh.csh.ksh等,习惯上把它们称作一种Shell.我们常说 ...

  3. 知问前端——Ajax登录

    本文,将使用Ajax登录. 一.服务器端代码 is_user.php: <?php require 'config.php'; $query = mysql_query("SELECT ...

  4. mysql数据库cmd直接登录

    找到mysql的安装路径: 将该路径配置到环境变量中: win+R代开dos窗口:输入mysql -uroot -p回车,输入密码.

  5. 【BZOJ】3790 神奇项链

    [算法](manacher+贪心)||(manacher+DP+树状数组/线段树) [题解] manacher求回文串,后得到线段,做一点计算映射回原串线段. 然后问题转化为可重叠区间线段覆盖问题,可 ...

  6. python自动开发之第二十二天

    知识点概要 - Session - CSRF - Model操作 - Form验证(ModelForm) - 中间件 - 缓存 - 信号 一. Session 基于Cookie做用户验证时:敏感信息不 ...

  7. C++学习之路(五):复制构造函数与赋值运算符重载

    之前没有细想过两者的区别,今天对此进行简要记录,后续完善补充. 复制构造函数是在类对象被创建时调用的,但是赋值运算符是被已经存在的对象调用完成赋值操作. 复制构造函数只在对象实例化时才被调用,即在复制 ...

  8. 安全测试===sqlmap(贰)转载

    十二.列举数据 这些参数用于列举出数据库管理系统信息.数据结构和数据内容. 1.一键列举全部数据 参数:--all 使用这一个参数就能列举所有可访问的数据.但不推荐使用,因为这会发送大量请求,把有用和 ...

  9. C 实现有追求的线程池 探究

    引言 线程池很普通的老话题,讨论的很多.深入的不多,也就那些基础库中才能见到这种精妙完备的技巧.而本文随大流 想深入简述一种高效控制性强的一种线程池实现. 先引入一个概念, 惊群. 简单举个例子. 春 ...

  10. C# 网络编程小计 20150202

    在学习网络Socket编程之前必须得学会多线程编程,这个是经常会用的到 可参考:http://www.cnblogs.com/GIS_zhou/articles/1839248.html System ...