Two water cups with mass interconnectivity can pour out any water volume from 1 to volume and

Source: Internet
Author: User

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.

  1. A is full, B is empty: A has 5 left, and B has 0 left.
  2. A's water is full. B: A has 2 left. B has 3 left.
  3. B is empty. A is flushed to B: A has 0 left, and B has 2 left.
  4. A is full: 5 for A and 2 for B.
  5. 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 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.