摘要: 已知一个函数f可以等概率的得到1-5间的随机数,问怎么等概率的得到1-7的随机数。----连续调用函数f两次,就能得到5*5=25种可能的组合串;抛弃最后的四个组合串,就有21中可能性,正好是7的倍数。php的简陋实现如下:<?phpfunction rand5to7 ($p){ switch ($p) { case '11': case '12': case '13': return 1; break; case '14': case '15': ... 阅读全文
posted @ 2013-06-10 16:51 stallman 阅读(177) 评论(0) 推荐(0) 编辑
摘要: "When the only tool you have is a hammer, every problem begins to resemble a nail."当你手里唯一的工具是锤子时,所有的问题看起来就像是钉子。"He that is good with a hammer tends to think everything is a nail."善用锤子的人倾向于把所有的事都看成钉子。"If the only tool you have is a hammer, you tend to see every problem as a n 阅读全文
posted @ 2013-06-10 15:29 stallman 阅读(1673) 评论(0) 推荐(0) 编辑