美文网首页
Codeforces 1C Ancient Berland Ci

Codeforces 1C Ancient Berland Ci

作者: pppppkun | 来源:发表于2019-06-05 22:47 被阅读0次

1C Ancient Berland Circus

题目意思就是,给出三个点的坐标,告诉你这三个点是某个正多边形中的三个点,让你求出这个正多边形的面积的最小值。

我们考虑到这个正多边形必然是内接在某个⚪里面,所以从圆心向这三个点连线,我们马上可以得到三个角,这三个角可以看作是正多边形内角的 某个倍数,所以我们找到这三个角的最大公因数是多少就相当于找到了内角,找到了内角就相当于找到了正多边形的面积,期间用到了余弦定理,三角形外接圆半径和三角形面积的关系,海伦公式。

#include<bits/stdc++.h>
using namespace std;
double pi=3.141592653589793238462643;
double pf(double a){
    return a*a;
}
double gcd(double a,double b){
    if (a<1e-3) return b;
    if (b<1e-3) return a;
    return gcd(b,fmod(a,b));    
}
int main(){
    double x1,y1,x2,x3,y2,y3;
    cin>>x1>>y1;
    cin>>x2>>y2;
    cin>>x3>>y3;
    double a = sqrt(pf(x1-x2)+pf(y1-y2));
    double b = sqrt(pf(x1-x3)+pf(y1-y3));
    double c = sqrt(pf(x2-x3)+pf(y2-y3));
    double p = (a+b+c)/2;
    double r=a*b*c/4/sqrt(p*(p-a)*(p-b)*(p-c));
    double alpha=acos((2*pf(r)-pf(a))/2/r/r);
    double beta=acos((2*pf(r)-pf(b))/2/r/r);
    double gama=2*pi-alpha-beta;
    double theta=gcd(gcd(alpha,beta),gama);
    printf("%.8lf",sin(theta)*(pi/theta)*r*r);
}

相关文章

  • Codeforces 1C Ancient Berland Ci

    1C Ancient Berland Circus 题目意思就是,给出三个点的坐标,告诉你这三个点是某个正多边形中...

  • codeforces-1C Ancient Berland Ci

    题意:给定一个正多边形三点坐标,求能组成的正多边形的最小面积。思路:1、根据三点坐标计算三边长度,然后计算该三点所...

  • Codeforces Round #697 (Div. 3)

    C. Ball in Berland[https://codeforces.com/contest/1475/pr...

  • Codeforces 1359A - Berland Poker

    不知道这辈子有没有机会买套这样的房子,哈哈哈哈哈哈。 翻译 扑克游戏需要一副 n 张牌,有 m 个鬼牌,k 个玩家...

  • Codeforces1073D——Berland Fair

    (code来源:https://blog.csdn.net/qq_38735931/article/details...

  • Dubstep

    Polycarpus works as a DJ in the best Berland nightclub, a...

  • 寒假3.2

    Vasya works as a DJ in the best Berland nightclub, and he...

  • find

    find 路径 条件 -size -1c小于1字节 +1c大于1字节 1c等于1字节的

  • Dubstep

    传送门 Vasya works as a DJ in the best Berland nightclub, an...

  • Learn C the Hard Way Ex2:Using M

    Makefile imply dependencies and ancient lore ancient lore...

网友评论

      本文标题:Codeforces 1C Ancient Berland Ci

      本文链接:https://www.haomeiwen.com/subject/awjexctx.html