HDU-5979 Convex

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37753409/article/details/82927715

HDU-5979 Convex
题意: 给定一个多边形, 绕中心的角度和长度给定。
分析: 直接遍历一遍求每个对应的三角形面积, 求和。

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592654;
int main () {
    double res = 0;
    int n;
    double d;

    while (cin >> n >> d) {
        res = 0;
        for (int i = 0; i < n; i++) {
            double x;
            cin >> x;
            res += (d*d*sin((PI*x)/180.0))/2;
        }
        printf ("%.3f\n", res);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37753409/article/details/82927715