P29051 [洛谷] [NOI2000] Ceramic Bead Necklace
普及-
题目描述

Problem Description

In a primitive tribe, they use a rare type of clay to bake circular ceramic beads with the same diameter and string them into necklaces. When stringing, they connect the beads along the diameter without gaps or overlaps, and a necklace consists of at least one bead.

The figure below shows a necklace made by stringing four identical beads together, with the total length being four times the diameter of a single bead.

Each baked bead has a constant thickness, and the diameter \( D \) is related to the volume of the clay used \( V \) by the following formula:

\[ D = \begin{cases} 0.3\sqrt{V-V_0} & \text{if } V > V_0 \\ 0 & \text{if } V \leq V_0 \end{cases} \]

where \( V_0 \) is the loss for each bead, measured in the same units as \( V \). If the clay used is less than or equal to \( V_0 \), it cannot be baked into a bead.

Example: If \( V_{\text{total}} = 10 \) and \( V_0 = 1 \), baking one bead would use \( V = V_{\text{total}} = 10 \) and \( D = 0.9 \). If the clay is evenly divided into 2 parts, each part would have \( V = \frac{V_{\text{total}}}{2} = 5 \), and the diameter of a single bead would be \( D' = 0.3 \times \sqrt{5-1} = 0.6 \), resulting in a total length of \( 1.2 \).

Given the total volume of clay and the loss for each bead, different numbers of beads baked will yield different total lengths of necklaces. Calculate the number of beads to bake to achieve the longest necklace.

Input Format

There are two lines, each containing a single integer.

The first line is the total volume of clay \( V_{\text{total}} \) ( \( 0 < V_{\text{total}} < 60000 \) ), and the second line is the loss for each bead \( V_0 \) ( \( 0 < V_0 < 600 \) ).

Output Format

A single line containing an integer.

This integer is the number of beads to bake to get the longest necklace. If no beads can be baked or if the optimal solution is not unique (there are two or more solutions that yield the longest necklace), output 0.

Sample Input and Output

Sample Input #1

48
7

Sample Output #1

3

Sample Input #2

8
5

Sample Output #2

1
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
48 7
样例输出
3