eolymp
bolt
Try our new interface for solving problems
Problems

Torus Travel

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.

prb8717.gif

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 his journey in a city on the inner road.

Input

The first line contains three integers: r, R - minor and major torus radiuses and n - number of countries (1r < R109, 1n109).

Output

Output should contain one real number minimal distance Senya has to cover. Your answer should have an absolute or relative error not greater than 10-9.

Example

In the second example let ik, sk, nk, ok represent the cities of k-th country on the inner, southern, northern and outer roads, accordingly. One of the minimal paths looks like: i1s1s2i2i3n3i3i4s4. 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 = 6pi18.849555922.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 2 1
Output example #1
1.570796327
Input example #2
1 3 4
Output example #2
18.849555922
Source 2018, XXVI Командный чемпионат школьников Санкт-Петербурга по программированию, 18 октября, Задача I