That is:Two water cups A and B, respectively. The volume is X and Y, (x, y) = 1. Then, we can pour out any natural volume of water from 1 to (x + y) by mutual pouring. (Assuming unlimited sleep)
Example:X = 5, y = 3, and 4 liters of water are poured out.
- A is full, B is empty: A has 5 left, and B has 0 left.
- A's water is full. B: A has 2 left. B has 3 left.
- B is empty. A is flushed to B: A has 0 left, and B has 2 left.
- A is full: 5 for A and 2 for B.
- A's water is full. B: A has 4 left. B has 3 left.
Mathematical proof:(From: http://www.guokr.com/question/206848)
The first case: water supply is unlimited.
Assume that there are two cups with the volume X and Y, respectively, and mutual quality, then for any integer a and B, the following same equation: (using = to represent the same symbol)
Z = a (mod X)
Z = B (mod y)
All have solutions. This conclusion is called the Chinese residue theorem, and its proof is a constructive proof, that is, the proof itself provides a solution to this equation.
Assume that x> Y, a is the volume of the required water, so that B = 0. To solve this equation, we can obtain an integer Z. The remainder of Z divided by Y is 0, so as long as a small cup of Z/Y water is used, and then poured to the large cup, the large cup is full, then all the light and then continued from the small cup, until Z is fully used up, the rest of the big cup is.
That is to say, this type of problem is always solved, but this solution may not be optimal (the minimum amount of water or the least number of tossing times ).
The second case: water is limited,For example, a large cup starts with X litre, and a small cup starts with y litre.
In this case, the third container is required. If the container is large enough, it should be the same as in the first case.
If the third container is small, more discussions are needed (smaller than a small cup, smaller than a small cup ).