#P5753. Optimal Ceramic Necklace

    ID: 18981 Type: Default 1000ms 256MiB

Optimal Ceramic Necklace

Optimal Ceramic Necklace

A primitive tribe crafts circular ceramic plates from a rare type of clay. All plates have the same diameter, and they are strung together to form a necklace. The plates are connected sequentially along their diameters with no gaps or overlaps, and a necklace contains at least one plate.

The diameter D of a ceramic plate is determined by the volume V of clay allocated to that plate and a fixed loss V0 incurred during firing. The relation is given by:

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

The tribe has a total clay volume Vtotal. If the clay is equally divided to produce n plates (with n being a positive integer), then each plate gets a volume \( V = \frac{V_{total}}{n} \), provided that \(\frac{V_{total}}{n} > V_0\) (otherwise no plate can be produced). The necklace length is simply \( n \times D \) (since the plates are connected along their diameters).

For example, when \( V_{total} = 10 \) and \( V_0 = 1 \):

  • If one plate is made, then \( V = 10 \) and \( D = 0.3\sqrt{10-1} = 0.9 \); necklace length = 0.9.
  • If the clay is divided into 2 parts, each plate gets \( V = 5 \) leading to \( D = 0.3\sqrt{5-1} = 0.6 \); necklace length = 1.2.

Your task is: Given \( V_{total} \) and \( V_0 \), determine the number of plates \( n \) that produces the longest necklace.

inputFormat

The input consists of two numbers: Vtotal and V0, separated by spaces. It is guaranteed that Vtotal > V0.

outputFormat

Output the optimal number of ceramic plates to produce the longest necklace.

sample

10 1
5