6.3 You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible.
得到1:装满3---从3倒进5---装满3---从3倒进5,此时3的瓶子里装的就是1.
得到2:装满5---从5倒进3,此时5的瓶子里装的就是2;
得到3:装满3;
得到4:装满5--从5倒进3--倒空3--从5倒进3(3里面有2)---装满5---从5再倒进3(倒进了1),现在5的瓶子里装的就是4;
得到5:装满5;
得到6:得到1之后再装满5就行;
得到7,得到2之后再装满5;
得到8, 装满3和5;
Careercup | Chapter 6,布布扣,bubuko.com
时间: 2024-10-13 01:07:40