• codeforces 630P. Area of a Star


    题目链接

    圆上n个点等距离分布, 求构成的星星的面积。

    我们可以求三角形OAB的面积, ∠CAE = 1/2 ∠ COE = PI/n, 那么∠CAO = PI/2n, ∠AOB非常好求, 就是PI/n, 然后AO = r, ∠ABO = PI-∠CAO-∠AOB, 就可以用正弦定理求出任意另外一条边, 然后s = 1/2absinC, 就可以求出来了。

    #include <iostream>
    #include <vector>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <map>
    #include <set>
    #include <string>
    #include <queue>
    #include <stack>
    #include <bitset>
    using namespace std;
    #define pb(x) push_back(x)
    #define ll long long
    #define mk(x, y) make_pair(x, y)
    #define lson l, m, rt<<1
    #define mem(a) memset(a, 0, sizeof(a))
    #define rson m+1, r, rt<<1|1
    #define mem1(a) memset(a, -1, sizeof(a))
    #define mem2(a) memset(a, 0x3f, sizeof(a))
    #define rep(i, n, a) for(int i = a; i<n; i++)
    #define fi first
    #define se second
    typedef pair<int, int> pll;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int mod = 1e9+7;
    const int inf = 1061109567;
    const int dir[][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };
    int main()
    {
        int n, r;
        cin>>n>>r;
        double ang1 = PI/n/2;
        double ang2 = PI/n;
        double ang3 = PI-ang1-ang2;
        double len = sin(ang1)*r/sin(ang3);
        double s = 0.5*r*len*sin(ang2);
        s = s*2*n;
        printf("%.8f
    ", s);
        return 0;
    }
  • 相关阅读:
    卷积:如何成为一个很厉害的神经网络
    卷积的本质及物理意义(全面理解卷积)
    傅里叶分析之掐死教程(完整版)
    buf.writeUInt16BE()
    buf.writeUInt8()函数详解
    buf.writeUIntBE()函数详解
    buf.writeInt32BE()函数详解
    buf.writeInt16BE()函数详解
    buf.writeInt8()函数详解
    buf.writeDoubleBE()函数详解
  • 原文地址:https://www.cnblogs.com/yohaha/p/5236451.html
Copyright © 2020-2023  润新知