一道蛮好玩的题目——某顶尖游戏公司程序员笔试第一题(摔xbox)

       今天,在论坛上看到一个很好玩的题目,特转载到这里分享下。虽然这道题目已经有一定年份了~~~(四年前的了)希望敢兴趣的人思考一下哦~~~

 

You have been given 2 special, extremely rugged Xboxes. You are in an office building that is 100 stories high. Using the fewest possible number of drops from windows in your office building, determine the highest floor you can drop an Xbox from and have it survive: for example, they might be able to take the drop from the 30th floor, but not the 31st. You can break both Xboxes in your search. State the worst case number of drops needed and explain how you arrived at that answer.

你在一幢100层的办公楼里上班,现在给你两台xbox(已经特意捆绑包扎好),要求你用尽可能少的试摔次数来判断xbox摔不坏的最高楼层层数。比方说,从30层丢下来没问题,但从31层丢下来就不保了。在摸索过程中,允许把两台xbox都砸烂。

详细解释你的答案和思路。  

 

PS:其中隐含了几个“公理”~~

 

公理1:所有的xbox都一样。
公理2:某一层上的任意位置均视为具有相同的高度。
公理3:xbox没有HP。换句话说,如果在某高度试摔xbox一次不烂,则在此高度无论摔多少次xbox也不会烂。
公理3:如果xbox在第x层摔不坏,则xbox在所有低于x层的楼层也一定不会摔坏

若不承认这些公理,这题就没意思了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值