2013年2月14日

Strange Towers of Hanoi(DP,汉诺塔)

摘要: Strange Towers of HanoiTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 2195Accepted: 1446DescriptionBackground Charlie Darkbrown sits in another one of those boring Computer Science lessons: At the moment the teacher just explains the standard Tower of Hanoi problem, which bores Charlie to 阅读全文

posted @ 2013-02-14 23:38 铁树银花 阅读(672) 评论(0) 推荐(0) 编辑

汉诺塔通项公式

摘要: 汉诺塔问题家传户晓,其问题背景不做详述,此处重点讲解在有3根柱子的情况下,汉诺塔问题求解的通项公式的推导。问题背景:有A,B和C三根柱子,开始时n个大小互异的圆盘从小到大叠放在A柱上,现要将所有圆盘从A移到C,在移动过程中始终保持小盘在大盘之上。求移动盘子次数的最小值。变量设置:n为圆盘个数,H(k)为n=k时移动盘子次数的最小值。递推公式: H(k)=2H(k-1)+1。通项公式:H(k)=2^k-1。证明:(1)证明递推公式:首先被移动到C盘的必定是最大的盘子,否则必定违反“在移动过程中始终保持小盘在大盘之上”的规定。既然要将最大盘移动到C,此时最大盘之上必定没有任何盘子,亦即它独自在一根 阅读全文

posted @ 2013-02-14 23:19 铁树银花 阅读(6144) 评论(0) 推荐(0) 编辑

World Cup Noise(DP基础)

摘要: World Cup NoiseTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 13853Accepted: 6827DescriptionBackground "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in their home country. But although their excitement is rea 阅读全文

posted @ 2013-02-14 17:35 铁树银花 阅读(572) 评论(0) 推荐(0) 编辑

Recaman's Sequence(简单)

摘要: Recaman's SequenceTime Limit: 3000MS Memory Limit: 60000KTotal Submissions: 19147 Accepted: 8028DescriptionThe Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the rsulting am is positive and not already in the sequence, otherwise am = am−1 + m. The first few numbers 阅读全文

posted @ 2013-02-14 11:16 铁树银花 阅读(431) 评论(0) 推荐(0) 编辑

导航