UCV2013I - Tambourine

no tags 

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).



Figure 2: (a) A tambourine. (b) The radius of the circles is shown. (c) There is a 2N sides regular polygon inscribed in the outter 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 fi nd the radius R of the big circle.


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.


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.


1 4
2 4
1 8
0 0 Output: 2.61

hide comments
bayulaxana: 2018-01-18 09:29:22

Use double instead of float. As many others said, take care the value of Phi.
don't use pi = 3.145926, but use M_PI for pi.
If you don't know what the M_PI do, try to search on Google.. it really helpful.

mishra_sharad: 2016-08-25 12:30:19

50th...in one go...just be careful about value of pi n take float...

sriraj: 2016-08-11 02:04:09

Using M_PI in C++ is a must

ajay_5097: 2016-04-10 23:45:26

that was the easy one AC in 1 go :)

queen_123: 2016-01-22 12:42:23


shubham_174: 2015-08-14 22:32:12

AC in 1st go..... :p
should be moved to tutorials....

Last edit: 2015-08-14 22:32:49
sy_117: 2015-08-14 21:51:51

Using pi=3.145926 & cosine formula give me 2 WA...So plz ...SINE Formula@@@@

Jaswanth: 2015-08-13 17:49:44

use M_PI (c++ math.h) rest of PI values give WA

kartikay singh: 2015-05-26 12:27:49

use double
float caused me 1 WA

anksin: 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!!!

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