2014/02/23

UVa 438 The Circumference of the Circle

http://acm.cs.nthu.edu.tw/problem.php?pid=7077
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793

int main(int argc, const char * argv[])
{

    double x1,x2,x3,y1,y2,y3,a,b,c,s,area,total,r;
    while (scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3) !=EOF) {
        a = sqrt(pow((x1-x2),2)+pow((y1-y2), 2));
        b = sqrt(pow((x1-x3),2)+pow((y1-y3), 2));
        c = sqrt(pow((x2-x3),2)+pow((y2-y3), 2));
        s = (a+b+c)/2;
        area = sqrt(s*(s-a)*(s-b)*(s-c));
        r = (a*b*c)/(4*area);
        total = 2*PI*r;
        printf("%.2lf\n",total);
    }
    return 0;
}