HDU 6354 Everything Has Changed

#include <iostream>
#include <cmath>
#define PI (acos(-1.0))
using namespace std;
int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        int n, R, a, b, c;
        double r, sum = 0;
        scanf("%d%d", &n, &R);
        sum = PI * 2 * R;
        while (n--)
        {
            scanf("%d%d%d", &a, &b, &c);
            r = sqrt(a * a + b * b);
            if (r >= R + c || r + c < R)
                continue;
            double a1, a2;
            a1 = 2 * acos((double)(r*r + c * c - R * R) / (double)(2.0 * r * c));
            a2 = 2 * acos((double)(r*r + R * R - c * c) / (double)(2.0 * r * R));
            sum += a1 * c - a2 * R;
        }
        printf("%.20lf\n", sum);
    }
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券