hdu 1374 三角形外接圆周长

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
typedef struct {
double x;
double y;
} MyPoint;
MyPoint p1, p2, p3;
const double PI = 3.141592653589793;

inline double xmult(MyPoint &p1, MyPoint &p2, MyPoint &p0) {
return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
}

inline double area_triangle(MyPoint &p1, MyPoint &p2, MyPoint &p3) {
return fabs(xmult(p1, p2, p3)) / 2;
}

inline double mydistance(MyPoint &p1, MyPoint &p2) {
return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
double a, b, c, s, R;
while (scanf("%lf%lf%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y)
== 6) {
s = area_triangle(p1, p2, p3);
a = mydistance(p1, p2);
b = mydistance(p1, p3);
c = mydistance(p2, p3);
R = a * b * c / 4 / s;
printf("%.2f\n", 2 * PI * R);
}
return 0;
}
posted @ 2011-10-19 13:50  moonbay  阅读(235)  评论(0编辑  收藏  举报