#P4160. Elegant Cake Division

    ID: 17408 Type: Default 1000ms 256MiB

Elegant Cake Division

Elegant Cake Division

Windy's birthday is here! His friends bought him a rectangular cake with side lengths (X) and (Y) to celebrate. There are (N) people (including Windy) and they want to share the cake so that each person gets an equal area of cake. Windy, acting as the chef, will perform exactly (N-1) cuts. Each cut must split one existing rectangular piece into two pieces by a straight cut parallel to one of its sides.

The twist is that to keep the pieces "beautiful," the ratio between the longer side and the shorter side of each piece (i.e. (\frac{\max(\text{side}_1,,\text{side}_2)}{\min(\text{side}_1,,\text{side}_2)})) is important. Your task is to determine the minimum possible value of the maximum such ratio among all pieces after partitioning the cake into (N) equal-area pieces.

It can be shown that an optimal strategy is to partition the cake in a grid-like fashion. In other words, if there exist positive integers (r) and (c) such that (r\times c=N), then by cutting the cake into a grid of (r) rows and (c) columns (or with the roles of (r) and (c) swapped), each piece will have dimensions either (\frac{X}{c}) by (\frac{Y}{r}) or (\frac{X}{r}) by (\frac{Y}{c}). The aspect ratio of a piece is given by (\frac{\max\left(\frac{X}{c},,\frac{Y}{r}\right)}{\min\left(\frac{X}{c},,\frac{Y}{r}\right)}) (or the analogous expression for the swapped assignment). Your goal is to choose an assignment that minimizes this maximum ratio over all pieces.

Input and output details are provided below.

inputFormat

The input consists of a single line containing three numbers: (N) (X) (Y). Here, (N) is the number of people (and pieces), and (X) and (Y) are the side lengths of the rectangular cake. (N) is an integer and (X) and (Y) are positive real numbers.

outputFormat

Output a single real number — the minimum possible value of the maximum ratio (\frac{\max(\text{longer side}, \text{shorter side})}{\min(\text{longer side}, \text{shorter side})}) among all cake pieces. The answer should be printed with precision up to 6 decimal places.

sample

3 1 2
1.500000