Area of a Star (Codeforces 630P)
Tags: Others, geometry

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 < 109, n 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.


Sample Inputs:
7 10

Sample Outputs:
108.395919545675

Solution (Python):
from math import *
(n, r) = map(int, input().split())
print(n * r * r / (1 / tan(pi / (2 * n)) + 1 / tan(pi / n)))

Solution (Python):
from math import tan, pi
(n, r) = map(int, input().split())
stri = r ** 2 / (2 * (1 / tan(pi / n) + 1 / tan(pi / (2 * n))))
print(2 * n * stri)

Solution (Python):
import math as mt
import sys
input = sys.stdin.readline

def inlt():
    return list(map(int, input().split()))

def invr():
    return map(int, input().split())
s = inlt()
n = s[0]
r = s[1]
rad = mt.pi / 180
Y = 90 - 270 / n
X = 180 - 2 * Y
X *= rad
Y *= rad
x = 2 * r * mt.sin(180 / n * rad)
y = x / (2 * mt.cos(Y))
area = 0.5 * x * y * mt.sin(Y)
A = 360 / n * rad
ans = n / 2 * r ** 2 * mt.sin(A) - n * area
print(ans)