Codeforces -- Sort ent Berland Circus (minimum polygon determined by three points)

Source: Internet
Author: User
Tags asin

Codeforces -- Sort ent Berland Circus (minimum polygon determined by three points)

 

Specified ent Berland Circus Time Limit:2000 MS Memory Limit:65536KB 64bit IO Format:% I64d & % I64u Submit Status Appoint description: System Crawler)

Description

Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.

In your ent Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coshould 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 specified ent Cirque 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 cocould 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 specified ent arena. this number shoshould 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.

Sample Input

Input
0.000000 0.0000001.000000 1.0000000.000000 1.000000
Output
1.00000000

 

Give three vertices and find the smallest positive polygon with these three points as the fixed point.

Find the smallest positive polygon, the more edges, the larger the area, so if the obtained polygon edge is as small as possible.

A triangle composed of three points can determine an external circle. all the points of the positive polygon should be on the circle, and the circle angle corresponding to the three sides should be obtained to find the maximum approximate number of the circle angle, the minimum number of edges of a polygon is obtained.

To prevent the blunt angle, the circle angle with the longest side is 2 * PI-the other two.

 

#include 
 
  #include 
  
   #include 
   
    #include using namespace std ;#define PI acos(-1)#define eqs 0.01double gcd(double a,double b){    return a < eqs ? b : gcd(fmod(b,a),a);}int main(){    double x1 , y1 , x2 , y2 , x3 , y3 ;    double a , b , c , p , s , r , k ;    double A , B , C ;    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3) ;    a = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;    b = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) ;    c = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) ;    p = ( a + b + c ) / 2.0 ;    s = sqrt( p * (p-a) * (p-b) * (p-c) ) ;    r = a * b * c / ( 4 * s ) ;    if( a > c )    {        k = a ; a = c ; c = k ;    }    if( b > c )    {        k = b ; b = c ; c = k ;    }    A = 2 * asin(a/(2*r)) ;    B = 2 * asin(b/(2*r)) ;    C = 2 * PI - A - B ;    //printf("%lf %lf %lf\n", A, B, C) ;    p = gcd(A,B);    p = gcd(p,C) ;    //printf("%lf %lf\n", r, p) ;    printf("%.6lf\n", (PI*r*r*sin(p))/p ) ;    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.