6.1

来源:互联网 发布:win10如何开启23端口 编辑:程序博客网 时间:2024/04/30 21:43

Topic: You have 20 bottles of pills. 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once.

// 关键:对每个瓶子要单独标记,称一次才可能称出来,所以第一个瓶子取1片,第二个2片,这样多了多少个0.1克,就是几号瓶子。

Take one pill from Bottle #1, two pills from Bottle #2, three pills from Bottle #3, and so on.Weigh this mix of pills, any grams more than (1+2+..+20)=210 must come the extra 0.1 grams pills.