The Towers of Hanoi Revisited Time Limit: 5 Seconds Memory Limit: 32768 KB Special Judge You all must know the puzzle named ��The Towers of Hanoi��. The puzzle has three pegs and N discs of different radii, initially all disks are located on the firs…
一.题目 http://acm.wust.edu.cn/problem.php?id=1223&soj=0 二.代码 import java.util.*; public class Main { Scanner in = new Scanner(System.in); int step, n; // step移动的步数,n盘子个数 /** * 构造方法 */ public Main() { while(in.hasNext()){ // 每次都重置为第一步 step = 1; // 输入盘子个…
3.4 In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (i.e., each disk sits on top of an e…