2014-03-20 01:08

题目:扔鸡蛋问题。有一个鸡蛋,如果从N楼扔下去恰好会摔碎,低于N楼则不碎,可以继续扔。给你两个这样的鸡蛋,要求你一定得求出N,怎么扔才能减少最坏情况下的扔的次数?

解法:为了让worst case得到最优化,就需要让best case和worst case最接近。具体做法请参见书上题解,因为我一直在想着二分,实在是摸不着头脑。

代码:

 // 6.5 Given 100 floors and 2 eggs.
// If the egg can sustain a dropping from nth floor, and will break for higher drop, please find a way to determine n, and minimize the number of droppings.
// Answer:
// That's indeed a brain teaser with mathematical principle.
// It just doesn't make sense to me, why it is optimized when num_of_drop(egg1) + num_of_drop(egg2) always stays the same.
// Perhaps you should read the book yourself. I do hope that I don't face such a question. Quite a teaser, tease me more.
int main()
{
return ;
}

最新文章

  1. C语言与内存模型初探
  2. tabs左右滚动
  3. 十九、【.Net开源】EFW框架核心类库之WCF控制器
  4. VS 自定义新建文件模板方法
  5. Java实验报告二:Java面向对象程序设计
  6. poj 1654 Area(多边形面积)
  7. 在静态页面html中跳转传值
  8. Python之路,Day15 - Django适当进阶篇
  9. A tutorial on Principal Components Analysis | 主成分分析(PCA)教程
  10. nagios 数据更新不及时的问题
  11. C语言描述栈的实现及操作(数组实现)
  12. iView 的分页结合表格用法
  13. nginx多虚拟主机优先级location匹配规则及tryfiles的使用
  14. C/C++关键字 new/delete和malloc/free
  15. Spring 3 Java Based Configuration with @Value
  16. ElasticSearch 2 (20) - 语言处理系列之如何开始
  17. C# MD5 32位加密 UTF-8编码
  18. Ubuntu下使用face_recognition进行人脸识别
  19. asp.net core发布到docker报Microsoft.ApplicationInsights.AspNetCore miss的错误
  20. ubuntu永久修改主机名

热门文章

  1. 笨办法学Python(六)
  2. windows服务器间文件同步搭建步骤搜集
  3. BZOJ 2735: 世博会 主席树+切比雪夫距离转曼哈顿距离
  4. 如何用代码填充S/4HANA销售订单行项目的数量字段
  5. jQuery获取Select选择的Text和Value[转载]
  6. SQL语句关于时间的查询小心得,希望大家给点意见
  7. java 通过接口在后台管理器中生成数据
  8. jsc
  9. P1089 津津的储蓄计划
  10. 20145238-荆玉茗 《Java程序设计》第4周学习总结