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\n", s);
    return 0;
}

 

posted on 2016-03-02 20:47  yohaha  阅读(374)  评论(0编辑  收藏  举报

导航