#P4820. Ant Book Overhang

    ID: 18064 Type: Default 1000ms 256MiB

Ant Book Overhang

Ant Book Overhang

Ants are known for their industrious nature, and now they face a challenging problem! The ants live in a library filled with identical rectangular books. They want to arrange these books on the edge of a horizontal table such that the books are placed horizontally with their width parallel to the table's edge (as shown in the figure), and no two books are placed at the same height.

The ants aim to maximize the horizontal overhang (i.e. how far the books extend beyond the edge of the table) while ensuring that the stack remains stable. A stack is considered unstable if for any book, the vertical projection of the center of mass of all books above does not lie strictly within the boundaries of that book (if it falls exactly on the edge, the stack is also unstable). The length of each book has been measured to be \(M\). Given \(N\) books in total, your task is to determine the maximum overhang that can be achieved without causing the stack to collapse.

Note: Under the idealized assumptions below, you may position each book at any real coordinate as long as the stack remains stable:

  • No effects of Earth’s rotation; gravitational acceleration is constant.
  • Every book is an ideal, uniform, rigid two-dimensional rectangle.
  • Books must be placed horizontally with their width parallel to the table edge.

Hint: The classical overhang problem shows that the maximum overhang achievable with \(N\) books is given by:

[ \text{Overhang} = \frac{M}{2} \sum_{i=1}^{N} \frac{1}{i} ]

Remember that if the center of mass of all books above any book does not lie strictly within that book, the structure will collapse. Use this formula to compute the maximum possible overhang.

inputFormat

The input consists of a single line containing two numbers \(M\) and \(N\) separated by a space, where \(M\) (a positive real number) is the length of each book and \(N\) (a positive integer) is the total number of books.

outputFormat

Output a single number representing the maximum overhang achievable (in the same units as \(M\)). The answer should be accurate up to at least 6 decimal places.

sample

10 1
5.000000