Codeforces Round #1 C Ancient Berland Circus (computational geometry)

Source: Internet
Author: User
Tags acos greatest common divisor

The idea of the problem is very good to think, divided into the following 4 steps:

1: Seek the radius of the circumscribed garden

2: Ask for three central angle

3: Find the greatest common divisor of three center angle

4: Greatest Common divisor is the largest regular polygon internal angle, to find the area can be.

But every step does not beg ah .... Sad ... When I think of the 3rd step, I even feel that I should ask for it in another way. To change the method. The geometry is too slag.

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 (XY) <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;}


Codeforces Round #1 C Ancient Berland Circus (computational geometry)

Related Article

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.