菲波那契数列 1,1,2,3,5,8,13……的第40位除以第39位得多少?即,N40/N39=?
a. 1.666666
b. 1.618xxx(后面几位记不清了)
c. 1.600000
d. 以上都不对
答案:b
N40/N39 = (N39 + N38) / N39 = 1 + N38 / N39 = 1 + 1 / (N39 / N38)
===> Dn = 1 + 1 / Dn-1
f(x) = 1 + 1/x, f(f(x)) = 1 + 1 / f(x), …
如果收敛,则趋近于
y = 1 + 1 / y ===> y^2 -y - 1 = 0 ===> y = (sqrt(5) + 1) / 2 = 1.6180339887…
实验室里有1000个一模一样的瓶子,但是其中的一瓶有毒。可以用实验室的小白鼠来测试哪一瓶是毒药。如果小白鼠喝掉毒药的话,会在一个星期的时候死去,其他瓶子里的药水没有任何副作用。请问最少用多少只小白鼠可以在一个星期以内查出哪瓶是毒药:
a. 9
b. 10
c. 32
d. 999
e. 以上都不对
参考答案:b
二进制编码
有一家人,老公、老婆、儿子还有老公的妈妈,其中有一个是律师,一个是医生
如果医生比律师年轻,则医生与律师没有血缘关系
如果医生的女的,那么医生和律师有血缘关系
如果律师是男的,医生也是男的
请问我们能确定这家人里的那一个人
a. 老公是医生
b. 老婆是医生
c. 儿子是医生
d. 老公的妈妈是医生
e. 以上都不对
答案:a
麦当劳有6块9块20块鸡的袋子,问大于等于N块的鸡都能正好用前述袋子装走的最小N是多少?正好的意思是每个袋子要么装满要么为空,答案是44
----------------
1,充分条件是:
如果n开始,能找到若干个20和若干个9之和,除以6的各个余数,1,2,3,4,5。
2,9和20组合一下,不难发现:
9 :
9 % 6 = 3,1次9
(9 + 9) % 6 = 0,2次9,没意义了,加1次有意义。
20 :
20 % 6 = 2,1次20,
(20 + 20) % 6 = 4,2次20,
(20 + 20 + 20) % 6 = 0,3次20,没意义,最多加2次。
20 和 9 组合,1次9,2次20:
(20 + 9) % 6 = 5,1次9,1次20
(20 + 20 + 9) % 6 = 1,2次20,1次9
3,求最小的
2中我们发现20 + 20 + 9 = 49,为了 余1,49以上肯定行,那么49一下的呢?
减掉一次循环,肯定不行,因为不能余1。但是除了余1,其他的都能余了,再加1就行。所以答案是:
49 - 6 + 1 = 44
----------------
这个问题可以用不等式解决:
首先要满足:
6x + 9y + 20z = N; ………………式1
然后还要分析如何用这几种类型的袋子实现N+1;可以得到:
6(x+2) + 9(y+1) + 20(z-1) = N+1 ……………式2
不难发现这个式子是实现N+1的最有效方式。
然后再分析如何用这几种类型的袋子 实现N+2;可以得到:
6x + 9(y-2) + 20(z+1) = N+2 ……………..式3
同样,这也是实现N+2的最有效的方法(原因是只比原来多用了一个袋子)。
再分析如何用这同种类型的袋子 实现N+3;可以得到:
6(x-1) + 9(y+1) + 20z = N+3; ……………..式4
同样,这也是实现N+3的最有效的方法。
再往下实现N+4,N+5,N+6……….直到N+无穷,都可以用实现N+1,N+2,N+3这两种组合实现,所以只要找到满足式2,式3, 式4 的条件的x,y,z即可。
这里必须满 足的条件是 z-1 >= 0(由式2 得出)即——–>z >=1
y-2 >= 0(由式3 得出)即———>y > = 2
x-1 >= 0(由式4得出)即———->x > = 1
所以,6x + 9y + 20z >=44.
完毕。
25匹马,每次赛5匹,问最少需要赛多少次可以决出前3名?
参考答案:25匹马分5组A,B,C,D,E,每组决出第一名A1,B1,C1,D1,E1;
5个第一名再赛一次,决出前三名A1,B1,C1;
然后再取(A2, A3, B1, B2, C1)赛出头两名即可。
1,2,3…n千克的砝码可以称出1,2,3..n千克的所有重量,那请问要想称出1,
2,3….n千克的所有重量,最少用多少砝码?
参考答案:1、3、9、27…
2=3-1,5=9-1-3,11=9+3-1,
飞机上有100个座位,按顺序从1到100编号。有100个乘客,他们分别拿到了从1号到100
号的座位,他们按号码顺序登机并应当对号入座,如果他们发现对应号座位被别人坐了,
他会在剩下空的座位随便挑一个坐。现在假如1号乘客疯了 -_-! (其他人没疯),他会在100
个座位中随机座一个座位。那么第100人正确坐自己座位的概率是多少?
答案:50%
如果1号乘客挑中1号座位,则第100人肯定可以坐到自己座位;如果挑中第100号座位,那么第100人肯定不会坐到自己的座位。
挑到1号座位与挑到100号座位的概率相同,设为x,此时不需考虑后继乘客的选择;
否则如果1号乘客没有挑到上面的两个座位(概率记为unknown),就需要继续考虑后继乘客的选择;
对于概率,如下公式成立:
1 = x + x + unknown
后继乘客怎样选择?
假设1好乘客挑到了第30个座位,那么从第2号到第29号乘客都正确坐到了自己的座位,下面轮到第30号乘客挑选。同样,挑到1号座位与挑到100号座位的概率相同,设为y,此时选择可以终止;未挑到这两个座位的概率记为unknown_2,此时需继续选择;
unknown = y + y + unknown_2
依次类推,直到所有乘客坐好。
可以看到,每次unknown里选中1号座位的概率始终和选中100号座位的概率相等,因此最后一个乘客正确坐到自己座位的为50%
有一个100层高的大厦,你手中有两个相同的玻璃围棋子。从这个大厦的某一层扔下围棋子就会碎,用你手中的这两个玻璃围棋子,找出一个最优的策略,来得知那个临界层面。答案:
One drop allows us to test 1 floor.Two drops can test 3 floors: Test the second floor first. If it breaks, test the first floor with the other ball. If not, test the top floor with either ball.Three drops can test 6 floors: Test the third floor first. If it breaks, test the bottom 2 floors in order with the other ball. If not, test the top 3 floors as described above.Four drops can test 10 floors: Test the fourth floor first. If it breaks, test the bottom 3 floors in order with the other ball. If not, test the top 6 floors as described above.N drops allows you to test the number of floors equal to the sum of 1 to n. Fourteen drops can test 105 floors: Test the fourteenth floor first. If it breaks, test the bottom 13 floors in order with the other ball. If not, test the twenty-seventh floor next (14 3), and so on.For any given drop, the number of drops you’ll need after that should be the same if that ball breaks or not (or sometimes they are off by 1 if your total is not an even sum-of-1-to-n).The optimum test protocol for 100 floors, then, requires a maximum of 14 drops. The next step is to derive a testing strategy that divides the 100 floors using the series 14+13+12+11+10+9+8+7+6+5+4+3+2+1.The best testing strategy starts with a drop from floor 14; then a drop from floor 27 (14+13); then 39 (14+13+12);etc. The full pattern is 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100.In practice, this series sacrifices the first ball to point to an everdecreasing series of possible target floors. A small number of drops using the second ball then identifies the target floor. Simply go back to the previously tested floor and start working up a floor at a time.Eventually,you will determine the floor at which the bowling ball shatters.This is the most efficient testing algorithm.
另外一种思路也很好,但是次数比14要大:类似于基数排序,将楼层数看成十位和个位,先用其中一个ball从10层、20层、30层一直往上测,最多到100层,总共尝试10次;当在某一层破碎,则在该层的下面10层尝试,比如第30层第一个球破碎,则在第21层、22层、23层一直到第29层尝试,相当于测试个位,总共尝试9次,最后加起来10+9=19次。
23枚硬币中有10枚是面朝上的,不许看,只许将硬币翻面(手摸不出正反面),现在要将这些硬币分成两组,两组中面朝上的硬币的数目相等,问如何分?
答案:将硬币分成10枚一堆和13枚一堆,将10枚那堆硬币全部翻转即可
A和B两个桶,分别装有10kg红色颜料和10kg蓝色颜料,现从A桶取一勺颜料装入B桶,搅拌均匀,再从B桶取同等质量的一勺装回A桶,问A桶中蓝色颜料占得比例和B桶中红色颜料的比例之间的关系?
答案:相等
A中的多出来的蓝色颜料部分和从A中分出去的红色颜料部分是一样多的
考虑极端情况:将A中全部颜料装入B中,再取一半回来
实际上,这道题的答案与搅拌均匀与否没有关系,和硬币的那道题类似
Allen and Brenda, both have a note stuck on their forehead, with a positive integer number written on it .Both Allen and Brenda can see each other’s number. They also know that the two numbers have a difference of one. They are trying to figure out the number on their own forehead.
Allen first says,”I don’t know my number.”
Brenda says,” I don’t know my number either”
Then Allen says “Now, I know my number”
Brenda now says, “Yeah, I know my number also!”
What is the number of Allen and Brenda?
A. 2,1
B. 1,2
C. 3,2
D. 2,3
E. 4,3
answer:C、E
Ctrl+a查看答案