fill A fill B empty A empty B pour A into B pour B into AAssuming that A and B are initially empty and that you have an unlimited supply of water, compute a sequence of operations that will leave c liters of water in either A or B. Note that the operation
pour A into B only
pours water from A into B until A is empty or B is full, whichever
comes first; no water is wasted. The operation pour B into A
works similarly.
The input consists of one or more lines, each containing three positive
integers a, b and c, separated by spaces. All numbers will be
less than 1000. For each line of input, output a sequence of operations that
solves the problem as shown in the examples below, or output the word
"impossible" if no solution exists. Note that spelling and punctuation
must be exactly as shown. The problems are numbered consecutively
beginning with #1.
Input must be read from the file "prob4.in", and output must be
written to the file "prob4.out". All output to the screen will be
ignored.
<BOF> 7 4 1 2 8 5 3 1 3 <EOF>
PROBLEM #1 fill B pour B into A fill B pour B into A B contains 1 liter of water PROBLEM #2 impossible PROBLEM #3 fill A A contains 3 liters of water