2013年6月16日

EOJ 1820 Hanoi Tower II

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1820汉诺塔变形:每步都得顺时针。(下图为逆时针)。记 f[n] 为 把n个盘从 s->t 不经中间节点。如(A->B, B->C, C->A)记 g[n] 为 把n个盘从 s->t 经中间节点。如(A->C, B->A, C->B)分析见下图: 1 #include <stdio.h> 2 3 int main() 4 { 5 unsigned long long f[45], g[45]; 6 f[1] = 1, g[1] = 2; 阅读全文

posted @ 2013-06-16 20:43 KimKyeYu 阅读(288) 评论(0) 推荐(0) 编辑

EOJ 1822 Hanoi Tower IV

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1822题意:双色汉诺塔,只是最终结果需保证相同大小的两块不倒置;容易想错:我最开始写成了:f[i] = 4*f[i-1] + 3;引用别人的题解:http://bbs.csdn.net/topics/270038285 1 #include <stdio.h> 2 3 int main() 4 { 5 long long f[65], //没有倒置. 6 g[65]; //只有最大的两个同尺寸盘子倒置 7 f[1] = 3, g[1] = 2; 8 for(in... 阅读全文

posted @ 2013-06-16 16:23 KimKyeYu 阅读(182) 评论(0) 推荐(0) 编辑

导航