Torus Travel
Torus is a surface that composed of points at a distance of r from a circle C with radius R in 3D space. C is then called a central circle of a torus; line perpendicular to the plane of C that also contains the centre of C is called torus' axis; R and r are major and minor torus radiuses, accordingly. A circle on a torus is called bigger if it’s centre is on torus’ axis and lesser if it’s radius is r and it’s plane contains torus’ axis.
Young traveller Senya lives on a torus-shaped planet with major radius R and minor radius r. There is a regular road map on this planet: n lesser roads at equal distance from each other (located on lesser circles), and 4 bigger roads (on bigger circles): outer — the most distant from the axis, inner — the least distant one, and also northern and southern equal to the central circle on the opposite sides of the planet.
Each lesser road is a property of one of n countries. Each country has only 4 cities on the intersections of it’s lesser road with all 4 bigger roads.
Left picture illustrates the definition and shows minor and major radiuses. The right one shows 4 greater roads and n = 3 lesser roads with cities on their intersections.
Senya wants to become The Great Traveller, which means that he wants to visit every country on the planet. He considers a country visited if he has travelled along the road between two different cities of this country. Of course, movement on his planet is allowed only by the roads.
Please, help Senya to find the distance he need to cover to become The Great Traveller, if he starts hisjourney in a city on the inner road.
Input
The first line contains three integers: r, R - minor and major torus radiuses and n - number ofcountries (1 ≤ r < R ≤ 10^9
, 1 ≤ n ≤ 10^9
).
Output
Output should contain one real number minimal distance Senya has to cover. Your answer should havean absolute or relative error not greater than 10^(-9)
.
Example
In the second example let i[k]
, s[k]
, n[k]
, o[k]
represent the cities of k-th country on the inner, southern, northern and outer roads, accordingly. One of the minimal paths looks like: i[1]
→ s[1]
→ s[2]
→ i[2]
→ i[3]
→ n[3]
→ i[3]
→ i[4]
→ s[4]
. Covered distance equals to 5 / 4 of country length, two segments of inner road and one of southern. So the answer is 5/4 * 2pi * 1 + 2 * 2pi * 2 / 4 + 2pi * 3 / 4 = 6pi ≈ 18.849555922.