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