UCV2013I - Tambourine

Little HH loves tambourines. He loves them so much that now he wants to build them. A tambourine is a musical instrument shown in Figure 1(a). As you can see in Figure 1(b) the tambourine is just a big circle of radius R with N smaller circles of radius r (r < R).

Tambourine

Figure 2: (a) A tambourine. (b) The radius of the circles is shown. (c) There is a 2N sides regular polygon inscribed in the outer circle

HH knows the radius of the small circles (r), he also knows the number of small circles that he has (N). And he knows that the small circles should be centered on the center of the even sides of a 2N sides regular polygon inscribed in the big circle (the sides of this polygon each measuring 2r), as shown on Figure 1(c). Now HH wants you to help him find the radius R of the big circle.

Input

The input contains several test cases. Each test case consists of two values r and N as described previously. (0 < r <= 100), (2 <= N <= 10000).

The end of input is indicated by a test case with r = N = 0.

Output

For each test case you must print a number (rounded up to two decimal places) showing the radius of the big circle to build the tambourine.

Example

Input:
1 4
2 4
1 8
0 0 Output: 2.61
5.23
5.13

Added by:Hector Navarro
Date:2013-07-22
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Local UCV 2013. Héctor Navarro

hide comments
2015-08-13 17:49:44 Jaswanth
use M_PI (c++ math.h) rest of PI values give WA
2015-05-26 12:27:49 kartikay singh
use double
float caused me 1 WA
2015-05-20 00:09:08
Use math.h M_PI for pi constant.......easy trigonometry.....any side of the polygon will subtend an angle at the center, and using Right Angle Triangle we can easily find the radius!!!
2015-05-10 11:46:07 kshitij tripathi
use pi=acos(-1)..
btw my 50th on spoj :)
2015-02-07 12:46:39 jaswin kaur
so easyyy!!!
my 50th :D
2015-01-12 14:45:43 Abhinandan Agarwal
use acos (-1) ... i used 3.14159 , got 1 WA :(
2014-12-04 18:18:59 Hi
pi=3.14159265358979 does work....i got AC in 1st try
2014-08-18 10:37:21 Diksha Jaiswal
simple...:D
2014-07-03 18:35:04 Surendra
also u can use M_PI in gcc 4.2.3 as value of pi. seriously easy.
2014-07-03 13:10:53 krishna kumar
donnot use cosine rule !!
caused me 10 WA's :(
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.