NOI '99 P3 - Birthday Cake
View as PDFNational Olympiad in Informatics, China, 1999
July 17th is Mr. W's Birthday, and ACM-THU would like to
create for him a birthday cake with volume , comprised of 
cylindrical layers.

Counting upwards from the bottom layer, the -th 
layer of cake is a cylinder with a radius of 
 and a height of
. When 
, we require for 
 and 
.
To reduce the money spent on icing the cake, we would like to minimize
, the outer surface area of the cake (not including the bottom
surface of the bottommost layer).
Let . Please write a program that, given 
 and 
, finds a
strategy to construct the cake (with appropriate 
 and 
values) that minimizes the value of 
.
Other than , all values described above will be positive integers.
Input Specification
The input will consist of two lines. The first line is the integer 
, indicating that the volume of the cake is 
. The
second line of input is the integer 
 
, representing the
number of levels in the cake.
Output Specification
The output should consist of one line - a positive integer  (if no
answer, 
).
Sample Input
100
2
Sample Output
68
Formulas for cylinders:
Volume: 
Side surface area: 
Bottom surface area: 
Problem translated to English by .
Comments