#t252. Hanoi 双塔问题
Hanoi 双塔问题
[NOIP 2007 Junior] Double Tower of Hanoi
Problem Description
Given three sufficiently long pegs A, B, C. On peg A there are center-holed disks, of different sizes, and for each size there are exactly two identical disks (the two disks of the same size are indistinguishable). The figure below shows the case .

The goal is to move all these disks onto peg C, using peg B for temporary storage during the process. Requirements:
- Only one disk may be moved at a time;
- On pegs A, B, and C, the disks must always remain in order of decreasing size from bottom to top.
Task: Let be the minimum number of moves needed to complete the task for disks. For the given , output .
Input Format
A positive integer , meaning there are disks on peg A.
Output Format
A positive integer: the minimum number of moves needed to complete the task.
Sample Input 1
1
Sample Output 1
2
Sample Input 2
2
Sample Output 2
6
Constraints
- For of the data, ;
- For of the data, .
Hint
Try to derive a recurrence relation between and .