National Olympiad in Informatics, China, 2000
Ancient tribes heated up a rare type of clay to produce ceramic disks with identical diameters. These disks are strung together to make necklaces by being joined along their diameters with no spaces or overlaps between them. Each necklace is made up of at least one disk.
The figure below depicts four rings of the same size, linked together to form a necklace with a length four times that of a single disk's diameter.
Each heat-crafted ceramic disk has a fixed thickness, while the diameter
where
Ex: Let
Given the total volume of clay and the amount lost for a single disk, and given that the number of disks produced is different, as well that the lengths of the final necklaces are also different, please calculate the number of disks produced that would maximize the length of the necklace.
Input Specification
The input consists of two lines, each containing a single integer. The
first line contains
Output Specification
The output should consist of one integer - the number of disks in the
necklace with the maximally obtainable length. If it is not possible to
produce disks or the answer is not unique (i.e. there exists two or more
ways to obtain the longest possible necklace), output the number 0
.
Sample Input 1
10
1
Sample Output 1
5
Sample Input 2
10
2
Sample Output 2
0
Problem translated to English by .
Comments