Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Quarantined With Circles

By Mehedi_Hassan · Limits 1s, 512 MB

You are given radius RR of a circle. Let’s call it “Main Circle”. You have to draw NN circles outside this main circle such that they follow the rules below -

(Compare with the picture below for better understanding)

  1. Every outer circle touches the main circle.

  2. Every outer circle touches exactly two more outer circles.

Find the area of the blue region.

Input

The first line contains an integer TT (1T103)\left(1 ≤ T ≤ 10^3\right), the number of test cases.

The next TT lines contains two integers, RR (1R105)\left(1 ≤ R ≤ 10^5\right) — radius of the main circle and NN (3N105)\left(3 ≤ N ≤ 10^5\right) — number of outer circles.

Output

For each test case, print the area of the blue region.

Your answer is considered correct if its absolute or relative error doesn't exceed 10610^{-6}. Namely, if your answer is aa, and the jury's answer is bb, then your answer is accepted, if abmax(1,b)106\frac{|a-b|}{max(1, |b|)} \leq 10^{-6}

Sample

InputOutput
3
3 8
4 4
500 8
5.927964
29.785152
164665.680333

Discussion

Statistics


93% Solution Ratio

woolgathererEarliest, 1M ago

BigO_cutterFastest, 0.0s

woolgathererLightest, 131 kB

Hamim_CuetShortest, 447B

Submit

Login to submit

Editorial

Here θ1=2π2n=πn.\theta_1 = \frac{2 \pi }{2n} = \frac{\pi }{n}.θ1​=2n2π​=nπ​. As OBOBOB is tangent t...