#P1760. Hanoi Tower Puzzle: Count the Moves

    ID: 15045 Type: Default 1000ms 256MiB

Hanoi Tower Puzzle: Count the Moves

Hanoi Tower Puzzle: Count the Moves

In a quest to retrieve a lost map hidden in a mysterious chest at the foot of a mountain, you encounter a classic puzzle: the Tower of Hanoi. The puzzle consists of three rods and \( n \) disks initially placed on one rod. The objective is to move all the disks to another rod obeying these rules:

  • Only one disk can be moved at a time.
  • Each move consists of taking the upper disk from one stack and placing it on top of another stack or an empty rod.
  • No disk may be placed on top of a smaller disk.

The minimum number of moves required to solve the puzzle is given by the formula: \( T(n) = 2^n - 1 \). Your task is to calculate \( T(n) \) for the given number of disks \( n \).

inputFormat

The input consists of a single integer \( n \) (1 ≤ \( n \) ≤ 30), representing the number of disks.

outputFormat

Output a single integer representing the minimum number of moves required to solve the Tower of Hanoi puzzle.

sample

1
1