P28855 [洛谷] [National Training Team] Book Stack
提高+
题目描述

Problem Description

Ants are diligent creatures who love to challenge their limits. Now they face a difficult problem! Ants live in a library filled with a vast number of books. These books are rectangular in shape, size, and mass, all identical. The ants want to place these books at the edge of a horizontal table. They prefer a neat arrangement, so they stipulate that the books must be placed horizontally, with their width parallel to the edge of the table (as shown in the figure), and no multiple books can be placed at the same height.

Image

The ants want to extend the books as far as possible beyond the edge of the table without them collapsing under gravity. They have already measured the length of the books, denoted as M (as shown in the figure). If there are a total of N books, please help calculate how to arrange them to achieve the maximum horizontal extension beyond the table edge. You do not need to consider how the ants build this stack of books.

If the vertical projection of the center of gravity of all the books above a certain book does not fall on that book, or exactly on its boundary, then the stack is unstable and will collapse under gravity.

Consider the following assumptions:

  • Earth's rotation is not considered, and the gravitational coefficient does not change with height;
  • The books are uniformly dense, rigid ideal two-dimensional objects;
  • Each book's position coordinates can be any real number, as long as the stack does not collapse.

Input Format

The first line contains two positive integers N and M.

Output Format

A single line (with a newline character) containing L, the integer distance of the farthest horizontal extension (the largest integer not greater than the answer).

Sample Input and Output

Sample Input #1

1 100

Sample Output #1

49

Sample Input #2

2 100

Sample Output #2

74

Notes

N <= 10^18, the data guarantees that the answer < 10^6.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 100
样例输出
49