Given V. $\mathbf{L}$.

a) 12 liters of milk were poured into a bucket. Using only 5-liter and 7-liter containers, divide the milk into two equal parts.

b) Solve the general problem: for which $a$ and $b$ can you divide $a+b$ liters of milk in half, using only $a$-liter, $b$-liter, and $(a+b)$-liter containers?

In one pouring from one container to another, you can either pour out everything that is in it or fill the second container to the top.
a) See the table:

![](https://cdn.mathpix.com/cropped/2024_05_06_7dfbf12cfa0901bdf2bfg-29.jpg?height=263&width=726&top_left_y=0&top_left_x=672)

Table 1.

b) Let $a \geq b$. We will call a container with a capacity of $a+b$ liters a reservoir, a container with a capacity of $a$ liters - the first container, and a container with a capacity of $b$ liters - the second container. We will prove that $c$ liters can be obtained if and only if $c = m a + l b$, where $m$ and $l$ are integers, $0 \leq c \leq a$. (If $a$ and $b$ are integers, then $c$ liters can be obtained if and only if $0 \leq c \leq a$ and $c$ is divisible by $\gcd(a, b)$ - see problem 69489.

Let $d_{k}$ be the "remainder" from the division of $k a$ by $b$ ($k=1,2,3, \ldots$): $d_{k} = k a - l_{k} b$, $0 \leq d_{k} < b$. We will show that for any $k$, there exists a $d_{k}$ such that $0 \leq d_{k} < b$. 

![](https://cdn.mathpix.com/cropped/2024_05_06_7dfbf12cfa0901bdf2bfg-29.jpg?height=215&width=1429&top_left_y=750&top_left_x=332)

Table 2.

![](https://cdn.mathpix.com/cropped/2024_05_06_7dfbf12cfa0901bdf2bfg-29.jpg?height=229&width=801&top_left_y=1009&top_left_x=637)

Table 3.

Now we will prove that $v$ liters can be obtained only if $v = m a + l b$. Indeed, suppose that after several pourings, the first container has $v_{1} = m_{1} a + l_{1} b$ liters, and the second container has $-v_{2} = m_{2} a + l_{2} b$ liters. (In reality, one of the containers is either empty or full, but we will not use this fact.) Then, no matter how we organize the next pouring, the number of liters in each container will be equal to $m a + l b$. In the case where the reservoir is used, this is obvious; the other cases are collected in Table 4.

![](https://cdn.mathpix.com/cropped/2024_05_06_7dfbf12cfa0901bdf2bfg-29.jpg?height=255&width=1335&top_left_y=1530&top_left_x=407)

Table 4.

From the proven fact, it follows that $1/2(a+b)$ liters can be obtained using pourings if and only if $1/2(a+b) = m a + l b$, from which we get

$(2 m - 1) a + (2 l - 1) b = 0$, or $\frac{a}{b} = \frac{2 l - 1}{1 - 2 m}$.

## Answer

If $a / b$ is rational, and the numerator and denominator of the corresponding irreducible fraction are odd.