#P1096. [NOIP 2007 普及组] Hanoi 双塔问题
[NOIP 2007 普及组] Hanoi 双塔问题
Description
Given three sufficiently long thin pegs A, B, and C, there are disks with holes on peg A. There are distinct sizes, and for each size there are two identical disks; note that these two disks are indistinguishable (the figure below shows the case ).

We need to move all these disks to peg C, and disks may be temporarily placed on peg B during the process. Requirements:
- Only one disk may be moved at a time.
- On pegs A, B, and C, the disks must always keep the order of smaller on top and larger below.
Task: Let be the minimum number of moves required to complete the task for disks. For the given , output .
Input Format
A positive integer , indicating there are disks on peg A.
Output Format
A positive integer, which is the minimum number of moves required to complete the task.
1
2
2
6
Hint
Constraints
- 对于 的数据,;
- 对于 的数据,。
Hint
Try to establish a recurrence relation between and .
Translated by ChatGPT 5
京公网安备 11011102002149号