Problem K
Rinse
Granny can upend the cream can, thus pouring its contents on the ground. But due to surface tension and the shape of the can a small amount of the content remains, even after the can is upended. Granny has a barrel full of rain water that she can use to rinse the can several times. Each rinse involves pouring some amount of water (perhaps none) into the cream can, mixing it thoroughly with the existing contents, and pouring it out. After each rinse an amount of liquid remains, some fraction of which is whiskey and the rest water.
Mr. Ness’ visit is imminent, affording Granny the time to do at most $k$ rinses. You are to determine a rinsing strategy that Granny should employ to minimize the amount of residual whiskey in the cream can after the last rinse.
Input
Standard input consists of several test cases, at most $10$. Each test case is represented by a line with five numbers:
-
$1 \le k \le 100$ – an integer denoting the maximum number of rinses
-
$0 < V_ b \le 200$ – a real number denoting the volume of available rain water in the barrel
-
$0 < V_ w \le 100$ – a real number denoting the volume of whiskey in the cream can
-
$0 < V_ r \le 100$ – a real number denoting the volume of liquid that cannot be poured out by upending the can (further liquid might be eliminated by evaporation, but there is insufficient time before Ness’ visit for any evaporation to take place)
-
$\max (V_ w, V_ r) < V_ c \le 200$ – a real number denoting the maximum capacity of the cream can.
All real numbers are given with at most $2$ digits after the decimal point. A line containing $0$ follows the last case.
Output
For each test case, output $r$, the number of rinses that Granny should perform. On the same line, output $r$ real numbers, giving the amount of rain water to be used for each rinse, in order.
Note that the total amount of water used in all rinses should not exceed $V_ b$, and the total amount of liquid in the cream should not exceed $V_ c$ at any time. Your solution will be accepted if these constraints are never violated by more than an absolute error of $10^{-6}$, and if the amount of residual whiskey left after the last rinse is within a factor $1 + 10^{-6}$ of the minimum possible.
Assume that whiskey and water mix perfectly and that their volumes are additive; that is, $x$ units of whiskey and $y$ units of water combine to form $x+y$ units of liquid.
Sample Input 1 | Sample Output 1 |
---|---|
2 15.0 25.0 1.0 50.0 0 |
2 0.00 15.00 |