Practice on Toph

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

Weird Cake

By nahidhasan98 · Limits 1s, 512 MB

A sphere-shaped cake is cut down with two parallel planes which gives three pieces of cake. The height of the initial cake is H. And the height of two cutting planes (from bottom) are h2 & h1 respectively.

See the picture for more clarification:

You have to tell the volume of each of these three pieces of cake.


Input contains several test cases. Each test case contains three space-separated integers H (4 ≤ H ≤ 1000), h1 and h2 (H/2 ≤ h2 < h1 < H).


For each test case, print "X Y Z" in a single line without the quotation marks, where X Y Z are the volumes of the three pieces of cake in non-decreasing order. The answer is considered correct if the absolute error does not exceed 10- 4.


10 8 6
54.454273 129.852496 339.292007



68% Solution Ratio

shegufaEarliest, Oct '19

perky_bunnyFastest, 0.0s

shegufaLightest, 131 kB

Omi074Shortest, 319B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.