eolymp
bolt
Try our new interface for solving problems
Problems

Curvy Little Bottles

Curvy Little Bottles

In her bike rides around Warsaw, Jill happened upon a shop that sold interesting glass bottles. She thought it might make an interesting project to use such bottles for measuring liquids, but this would require placing markings on the bottles to indicate various volumes. Where should those volume marks be placed? Jill formalized the problem as follows. Assume a bottle is formed by revolving a shape that is the same as the graph of a polynomial \textbf{P} between \textbf{x = x_low} and \textbf{x = x_high} around the \textbf{x}-axis. Thus the \textbf{x}-axis is coincident with a vertical line through the center of the bottle. The bottom of the bottle is formed by a solid circular region at \textbf{x = x_low}, and the top of the bottle, at \textbf{x = x_high}, is left open. The first sample input represents a bottle formed using the simple polynomial \textbf{4-0.25x}, with \textbf{x_low = 0} and \textbf{x_high = 12}. The bottom of this bottle is a circle with a radius of \textbf{4}, and the opening at the top is a circle with a radius of \textbf{1}. The height of this bottle is \textbf{12}. Volume markings are in increments of \textbf{25}. Given a polynomial \textbf{P}, \textbf{x_low}, \textbf{x_high}, and the volume increment between successive marks on the bottle, compute the distances up from \textbf{x_low} for the marks at successive volume increments. A mark cannot be made past the top of the bottle, and no more than the first \textbf{8} increments should be marked. Assume the value of \textbf{P} is greater than zero everywhere between \textbf{x_low} and \textbf{x_high}. \InputFile Each test case consists of three lines of bottle data: \begin{itemize} \item Line \textbf{1}: \textbf{n}, the degree of the polynomial (an integer satisfying \textbf{0} ≤ \textbf{n} ≤ \textbf{10}). \item Line \textbf{2}: \textbf{a_0}, \textbf{a_1}, ..., \textbf{a_n}, the real coefficients of the polynomial \textbf{P} defining the bottle’s shape, where \textbf{a_0} is the constant term, \textbf{a_1} is the coefficient of \textbf{x^1}, ..., and \textbf{a_n} is the coefficient of \textbf{x^n}. For each \textbf{i}, \textbf{-100} ≤ \textbf{a_i} ≤ \textbf{100}, and \textbf{a_n} ≠ \textbf{0}. \item Line \textbf{3}: \begin{itemize} \item \textbf{x_low} and \textbf{x_high}, the real valued boundaries of the bottle (\textbf{-100} ≤ \textbf{x_low} < \textbf{x_high} ≤ \textbf{100} and \textbf{x_high}-\textbf{x_low} > \textbf{0.1}). \item \textbf{inc}, an integer which is the volume increment before each successive mark on the bottle (\textbf{1} ≤ \textbf{inc} ≤\textbf{ 500}). \end{itemize} \end{itemize} \OutputFile For each test case, display the case number and the volume of the full bottle on one line. On a second line, display the increasing sequence of no more than 8 successive distances up from the bottom of the bottle for the volume markings. All volumes and height marks should be accurate to two decimal places. If the bottle does not have a volume that allows at least one mark, display the phrase \textbf{insufficient volume}. No test case will result in a mark within \textbf{0.01} from the top of the bottle. The volume of the bottle will not exceed \textbf{1000}. All rounded distances for marks on a bottle differ by at least \textbf{0.05}.
Time limit 3 seconds
Memory limit 256 MiB
Input example #1
1
4.0 -0.25
0.0 12.0 25
Output example #1
Case 1: 263.89
0.51 1.06 1.66 2.31 3.02 3.83 4.75 5.87
Source ACM-ICPC World Finals 2012