Create Apollonian Gasket code

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.

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


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 3 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 1


17.000000 40.000000 1.000000


2439.259 835.263  

Example 2


10.000000 10.000000 2.000000


261.799 146.608  


Example 3


2.000000 50.000000 1.000000


2066.462 408.747  

Example 4


1000.022000 811.047000 0.025000


2575261.696 292760.964

P.S Code should be written with the help of 2D or 3D or moreD matrices without using Numpy

Compétences : Python

en voir plus : create subdomain php code, create executable sorce code, create fake zip code, visual create dll sample code, create dll existing code, create template photoshop code till html, excel data create xml vba code, create zshare embed code, create short unique code email php, aspnet create iis website code, create login php code without database, create rebar sample code, create xls file code php, create random alphanumeric code php, create exe source code, create iis site code, create kml vb6 code, create paypal discount code, create aouto generate code aspnet

Concernant l'employeur :
( 0 commentaires ) Prague, Czech Republic

Nº du projet : #19948734

2 freelance font une offre moyenne de €23 pour ce travail


Hello Sir/ Ma’am As a highly skilled full stack developer, I have rich experience in JAVA, C, C++, C# Python and ANDROID. I am very confident with my skills and I'd like to help your business by doing my best. My cli Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 7 jours
(6 Commentaires)

I am skilled in python... and I am very good in python... I have won on many rounds in competitive programming (codearena) in [login to view URL] I think I am suitable to solve this problem.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(0 Commentaires)