My MSN

Click OK to add this content

 
Content Preview: rss
-+赛马(抄的)
428 days ago
有36匹马,六个跑道?没有记时器等设备,用最少的比赛次数算出跑的最快的前三名马?   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   其实用排除法就可以把过程看的很清楚了,前面的步骤一样,6组分别比之后6个第一名比,这时候,假设排名为:A1、 B1、 C1、 D1、 E1、F1,此时可以断定A1为最快的马,然后排除法,看那些不可能是前三: 1、D,E,F组全部排除; 2、A组后三名全部排除(前面至少已经有A1,A2,A3); 3、B组后四名全部排除(前面至少已经有A1,B1,B2); 4、C组其实后五名都可以排除(前面至少已经有A1,B1,C1); 剩下的就只有:A2、A3、B1、B2、C1,跑一次ok了
-+Coins game
434 days ago
N coins lay linear. Two men are taking them in turn. They can take one coin or adjacent two per time. 1. The one who takes the last coin is winner. Please analyze the strategy. 2. The one who takes the last coin is loser. Please analyze the strategy.   s = { (1,):0 } def perm(L): for i in range(len(L)): for j in range((L[i]+1)/2): yield sorted(k for k in L[:i]+[j,L[i]-j-1]+L[i+1:] if k>0) yield sorted(k for k in L[:i]+[j,L[i]-j-2]+L[i+1:] if k>0) def win(L): k = tuple(L) r = s.get(k) if r is not None: return r for l in perm(L): if not win(l): s[k] = 1 return 1 s[k] = 0 return 0 for i in range(1, 100): print i, win([i]) print len(s)   I found hardly to understand the python. -_-!!!!!!!!!!
-+quick sort(Bentley-McIlroy 3-way partitioning)
435 days ago
Partitioning invariant move from left to find an element that is not less move from right to find an element that is not greater stop if pointers have crossed exchange if left element equal, exchange to left end if right element equal, exchange to right end Partitioning invariant Swap equals to center after partition KEY FEATURES always uses N-1 (three-way) compares no extra overhead if no equal keys only one “extra” exchange per equal
-+Output[i] will be multiplication from A[0] to A[N] excluding A[i]
435 days ago
suppose there is an array A[N] of N numbers. We have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n). ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ In C#:     static int[] array_multiplier( int[] inp)     {         int[] x = new int[inp.Length];                  x[0] = 1;         for (int i = 1; i < x.Length; ++i) {             x[i] = x[i-1] * inp[i-1];         }                  int[] y = new int[inp.Length];                  y[y.Length-1] = 1;         for (int i = y.Length-2; i >= 0; --i) {             y[i] = y[i+1] * inp[i+1];         }                  int[] output = new int[inp.Length];         for (int i = 0; i < output.Length; ++i) {             output[i] = x[i] * y[i];         }          ...
-+发个旧文《装b指南》
534 days ago
我是一工薪族,以下是本人多年装b的一些肤浅经验,我把它们写出来与工薪阶层的其他装b爱好者们分享,希望通过此文起到抛砖引玉的作用,以便与大家互通有无彼此借鉴取长补短,在今后的工作和生活中更加求真务实勤学苦练,创造性地装b。白领、富豪之流的生活离我很远,我不知道人家的b怎么装,即便知道我也装不象,毕竟经济基础决定上层建筑,没有超越常人的智慧不要试图跨越式装b,以免装b不成反被x。   一.音乐   说到装b咋能不谈音乐捏,这可是装b的重要道具啊!   音乐在装b工作中我认为有两个要点需要掌握:1.对于过分流行、红得发紫的音乐不听、不唱、不评论、装没听说过;2.不轻易在人前暴露自己喜欢什么样的音乐,以免被x。   对于第一条,我们以前一段红得发紫的《老鼠爱大米》为例说明:我感觉喜欢《老鼠爱大米》的人——我说的是喜欢它的人,一听就讨厌的人不在讨论范围——可分4个境界:   ①最低,听人推荐后下载了这首歌,狂喜欢,并疯狂地向身边的朋友推荐,推荐过程中自尊心间或遭到打击,被骂“土鳖”、“俗人”次数若干;   ②听人推荐或自己发现并下载了这首歌,喜欢,但知道这首歌已经臭了街了,已经是上不了台面的东西了,不复再听,更不与人对此探讨交流,当有最低境界者①试图与自己交流对《老鼠爱大米》的感受时嗤之以鼻:“行了行了,歇菜吧你个土鳖,啥破歌啊你还听,我从来不听这种破玩意儿,俗得要命!要不怎么都说国人素质亟待提高呢……”打击①中主人公的便是此人;   ③听人推荐或自己发现后下载了这首歌,一听之下,喜欢,结合此歌的流行程度,怕被打击或鄙视,将其删除,某场合有人提及此歌时,佯作不知:“没听过,好听吗?”如果碰巧有mp3或手机能放这首歌,作恍然大悟状:“噢,这歌啊,听过听过,想不听都不行,马路上但凡能闹点动静的喇叭都在放!”作为自身修养的体现,到此赶紧打住,点到为止,别再穷追猛打了,我一向认为②中主人公的那种贬低别人品位的行为并不能有效地提升自身形象,反倒暴露了自己的低素质,一个一味试图提升自身形象而不懂得尊重别人的人不可能是一个成功的装b犯。 ...
© 2009 MicrosoftMicrosoft