Delicious Cookie
Time limit1sMemory limit512 MB
Split every piece of a right triangle with legs a and b N times along the altitude to the hypotenuse and print the natural log of the K-th largest piece area.
- Level
Medium5 of 10
- Topics
- Combinatorics, Geometry, Math
- Solved
- No attempts yet
Problem
Ellie's favorite cookie is shaped like a right triangle. Its two sides other than the hypotenuse have lengths and . One day Ellie thought of a way to eat a great many of these cookies.

Drop a perpendicular from the right angle to the hypotenuse and cut along it: one cookie splits into two right triangles. The total area does not change, but young Ellie was happy just to hold two cookies instead of one. Cutting both pieces the same way gives four pieces, then eight. Starting from a single right triangle cookie and cutting every piece she owns, repeated times, leaves pieces. Ellie has already finished those rounds and now holds pieces.
She decided the pile is too large, so she will give Peter the piece whose area is the -th largest. Write a program that finds the area of the piece Peter receives.
Input
The first line contains four positive integers , , , , separated by single spaces. (, , )
Output
Let be the area of the piece Peter receives. Print on the first line. The area itself can be extremely small, so the natural logarithm is printed instead of the area. Round it to exactly nine digits after the decimal point, padding with zeros when a digit is missing.