Jars and marbles 问题

You have 10 jars, each filled with many marbles. Each marble weighs exactly 1.0 grams. One of the jars is a bad batch meaning each marble inside weighs 1.1 grams instead of 1.0 grams. You have a scale that will give you back a number of how much things weigh on it. Using only one measurement, determine how would you be able to find the bad batch


scale是秤的意思


答案是:

Line up the jars in some fashion. 
Take 1 marble from the first jar 
Take 2 marbles from the second jar 
Take 3 marbles from the third jar 
and so forth up to the ninth jar 
Don't take any from the tenth jar 
 
Put the marbles on the scale. 
 
If the scale reads a whole number, then the tenth jar is the jar that contains the marbles that weigh 1.1g 
 
If the scale reads #.1 then it is the first jar that contains marbles that weigh 1.1g (1x1.1 will give you #.1)
 
If the scale reads #.2 then it is the second jar that contains marbles that weigh 1.1g (2x1.1 will give you #.2) 
 
If the scale reads #.3 then it is the third jar that contains marbles that weigh 1.1g (3x1.1 will give you #.3) 
 
and so forth 


如果一个jar里面可以有1个或两个1,1g 的marble,那么为了产生每个独立的组合,则下一个要比上一组大。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值