#P1731. [NOI1999] 生日蛋糕

[NOI1999] 生日蛋糕

Description

July 17 is Mr. W’s birthday. To celebrate, ACM-THU plans to make an MM-layer birthday cake with volume NπN\pi, where each layer is a cylinder.

Let the ii-th layer from bottom to top (1iM1 \leq i \leq M) be a cylinder with radius RiR_i and height HiH_i. For i<Mi \lt M, it is required that Ri>Ri+1R_i \gt R_{i+1} and Hi>Hi+1H_i \gt H_{i+1}.

Since the cake needs to be frosted, to save cost as much as possible, we want the area QQ of the cake’s outer surface (excluding the bottom face of the lowest layer) to be minimized.

Given NN and MM, write a program to find a construction of the cake (appropriate values of RiR_i and HiH_i) that minimizes S=QπS=\dfrac{Q}{\pi}.

(Except for QQ, all the quantities above are positive integers.)

Input Format

The first line contains an integer NN (N2×104N \leq 2 \times 10^4), indicating that the cake’s volume is NπN\pi.

The second line contains MM (M15M \leq 15), the number of layers of the cake.

Output Format

Output an integer SS. If there is no solution, output 00.

100
2

68

Hint

Translated by ChatGPT 5