枯葉北風寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令
感覺和上次codeforce的第四題有點像,雖然沒做出來,呵呵。看來枚舉左右子樹這一招還是蠻常用的。其實我本來想練下卡特蘭數(shù)的,結果變成練DFS了。注意遞歸求解左右孩子時的那兩個參數(shù),一定要先加上1,否則就不對了。
posted on 2010-04-13 17:33 abilitytao 閱讀(2142) 評論(5) 編輯 收藏 引用
srand(time(NULL)) 是以當前到1970年的時間間隔的秒數(shù)為種子,time(NULL),指不需要保存一個時間對象 通常情況下可以Time tTime;然后time(&tTime)來將這個時間獲取到。 而rand()是以剛才生成的種子為基礎來產(chǎn)生一個隨機數(shù),每調(diào)用一次產(chǎn)生一個數(shù),貌似如果期間沒有再次調(diào)用srand來生成種子,rand()是接著前面的序列來產(chǎn)生下一個數(shù)。(個人想法) 因為: srand(time(NULL)); int x = rand(); int y = rand(); x和y的值不一樣。而: srand(time(NULL)); int x = rand(); srand(time(NULL)); int y = rand(); 則是相同,因為后一種使用了同一個種子(運行期間時間很短,返回的秒數(shù)相同) 回復 更多評論
I can understand a[i] stores catalan number when there are i nodes.but what is b[] used for?Thanks,yoyo 回復 更多評論
@yoyo b[i]=a[1]+a[2]+...a[i]; 回復 更多評論
@abilitytao:-) I can know it from code, while no idea what's the purpose of b[i] = a[1]+...a[i]Thanks for quick replying.yoyo 回復 更多評論
@yoyo the intention is to find the node number of the the tree that you want. you are not chinese? or you can understand it through my notes by Chinese. 回復 更多評論
Powered by: C++博客 Copyright © abilitytao