zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    算法训练 接水问题
    算法训练 数组排序去重
    算法训练 A+B Problem
    算法训练 采油区域
    算法训练 会议中心
    JS高级
    JS基础操作
    JavaScript入门(基础)
    表格与表单
    音频与视频
  • 原文地址:https://www.cnblogs.com/moonbay/p/2217560.html
Copyright © 2011-2022 走看看