P9038 [PA 2021] Bottles
Description
Byteasar has three bottles of orange juice. He now wants to make exactly $k$ liters of orange juice in one of the bottles by pouring orange juice from one bottle into another. Since he does not have a measuring cup, the only allowed operation is to transfer orange juice between two bottles: either empty one bottle or fill one bottle to full. No orange juice may be spilled on the ground, and no orange juice may be added from outside these three bottles.
Byteasar now wants to know, for each $k$, what is the minimum number of transfers needed to make one of the three bottles contain exactly $k$ liters of orange juice. He hopes you can help him.
Input Format
The first line contains three integers $A, B, C$, the capacities of the first, second, and third bottles.
The second line contains three integers $a, b, c$, the initial amounts of orange juice in the first, second, and third bottles.
Output Format
Output one line with $C + 1$ integers. The $i$-th integer is the minimum number of operations if there exists a sequence of operations that makes one of the three bottles contain exactly $i - 1$ liters of orange juice; otherwise output $-1$.
Explanation/Hint
For $100\%$ of the testdata, $1 \leq A \leq B \leq C \leq 10^5$, $0 \leq a \leq A$, $0 \leq b \leq B$, $0 \leq c \leq C$.
Translated by ChatGPT 5