Codeforces 630P Area of a Star

来源:互联网 发布:mac qq截图失效 编辑:程序博客网 时间:2024/06/04 00:32

P. Area of a Star
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star.

A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts.


Input

The only line of the input contains two integers n (5 ≤ n < 109n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly.

Output

Output one number — the star area. The relative error of your answer should not be greater than 10 - 7.

Examples
input
7 10
output
108.395919545675

如图所示,角的分布,中间那三个角是相等的,然后对象为正7角形一角的一半所组成的小三角形,a为A所对应的边。至于C=2*B(圆周角是圆心角的一半)

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#define Pi acos(-1.0)using namespace std;int main(){    double n,A,B,C,a,b,c,s;    while(~scanf("%lf%lf",&n,&a))    {        C=Pi/n;        B=Pi/(2*n);        A=Pi-B-C;        b=a*sin(B)/sin(A);        s=a*b*sin(C)*n;        printf("%.8lf\n",s);    }    return 0;}


0 0
原创粉丝点击