Apollonian gasket
Quido is fond of Apollonian gaskets. They are planar fractals generated from
triples of circles, where each circle is tangent to the other two.
In his drawing of the gasket, Quido starts with two externally tangent circles which diameter is D1 and D2.
Then he adds a third circle which diameter is D1+D2 and to which the two original circles are
internally tangent. This is the first generation of circles.
Each subsequent generation of circles is constructed by applying the following scheme:
For any three circles A, B C of any previous generations which are tangent to each other
a new circle is constructed which is tangent to A,B,C. The new circle must differ
from all circles constructed so far.
When a generation is complete, i.e no other circle can be added,
then the next generation of circles can start being constructed.
Switch to other browser, pleeeease... :-) | Switch to other browser, pleeeease... :-) | Switch to other browser, pleeeease... :-) | Switch to other browser, pleeeease... :-) |
Image 1. Example of a gasket. The leftmost scheme shows the first generation, each next scheme contains one more generation of circles. |
There is an additional stopping rule which prevents Quido from generating infinitesimally small circles. A circle can be added to the gasket if and only if the lenght of its diameter is least minD which is a fixed positive value.
The task
Given the values D1, D2 and minD find the sum of areas and also the sum of perimeters of all circles in the gasket excluding the largest one.
Input
Input consists of one line with three decimal numbers D1, D2 and minD.
The number are separated by spaces. The format is usual decimal format (see also the examples bellow) with no exponent part.
It holds that 1.0 ≤ D1, D2 ≤ 1000.0, 0.001 ≤ minD ≤ D1+D2.
Output
Ouput consists of one text line containing two decimal numbers L1 and L2.
L1 represents the sum of areas of all circles in the gasket except for the bigggest circle.
L2 represents the sum of perimeters of all circles in tin the gasket except for the bigggest circle.
Both output values are rounded to 6 decimal digits.
Decimal digits must be always present in the output even if some of them are zeros.
Maximim output value is less than 107.
Example 1Input17.000000 40.000000 1.000000Output 2439.258588 835.263228 |
Switch to other browser, pleeeease... :-)
Image 2. The gasket corresponding to the input data of Example 1. |
Example 2Input10.000000 10.000000 2.000000Output 261.799388 146.607657 |
Switch to other browser, pleeeease... :-)
Image 3. The gasket corresponding to the input data of Example 2. |
Example 3Input2.000000 50.000000 1.000000Output 2066.462477 408.747226 |
Switch to other browser, pleeeease... :-)
Image 4. The gasket corresponding to the input data of Example 3. |
Example 4
Input1000.022000 811.047000 0.025000Output
2575261.696138 292760.963694
Public data
The public data set is intended for easier debugging and approximate program correctness checking. The public data set is stored also in the upload system and each time a student submits a solution it is run on the public dataset and the program output to stdout and stderr is available to him/her.
Link to public data set