Codeforces Round #1 C subject ent Berland Circus (Computational ry ),

Source: Internet
Author: User
Tags acos

Codeforces Round #1 C subject ent Berland Circus (Computational ry ),

The idea of this question can be divided into the following four steps:

1: Calculate the radius of the external shard

2: ask for three round angles.

3: calculate the maximum common approx.

4: The maximum common divisor is the biggest inner angle of the positive polygon. Just calculate the area.

But every step won't ask .... Sad... When I think of step 2, I even think that I should use other methods .. .. The ry is too scum.

The Code is as follows:

#include <iostream>#include <string.h>#include <math.h>#include <queue>#include <algorithm>#include <stdlib.h>#include <map>#include <set>#include <stdio.h>using namespace std;#define LL __int64#define pi acos(-1.0)const int mod=100000000;const int INF=0x3f3f3f3f;const double eqs=0.01;struct Point{    double x, y;}p[4];bool dmp(double x, double y){    return fabs(x-y)<eqs;}double fgcd(double x, double y){    if(dmp(x,0)) return y;    if(dmp(y,0)) return x;    return fgcd(y,fmod(x,y));}double dist(Point f1, Point f2){    return sqrt((f1.x-f2.x)*(f1.x-f2.x)+(f1.y-f2.y)*(f1.y-f2.y));}int main(){    double s, r, ang[4], d[4], pp, angle;    int i;    for(i=0;i<3;i++){        scanf("%lf%lf",&p[i].x,&p[i].y);    }    for(i=0;i<3;i++){        d[i]=dist(p[i],p[(i+1)%3]);    }    pp=(d[0]+d[1]+d[2])/2.0;    s=sqrt(pp*(pp-d[0])*(pp-d[1])*(pp-d[2]));    r=d[0]*d[1]*d[2]/(4*s);    ang[0]=acos(1-d[0]*d[0]/(2*r*r));    ang[1]=acos(1-d[1]*d[1]/(2*r*r));    ang[2]=2*pi-ang[0]-ang[1];    angle=fgcd(ang[0],ang[1]);    angle=fgcd(angle,ang[2]);    printf("%.6f\n",r*r*pi*sin(angle)/angle);    return 0;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.