#P1760. 通天之汉诺塔

    ID: 719 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟高精度递推递归洛谷原创

通天之汉诺塔

Description

With your help, Xiao A has collected valuable data and finally reached the legendary Sky Mountain that connects to the Sky Road. However, there is still some distance to the Sky Road, and Xiao A suddenly realizes he has no map. Fortunately, he finds a treasure chest at the foot of the mountain. Based on experience (does Xiao A even have any?), he judges that the map should be inside.

On the chest, there are three pegs and nn disks stacked on one peg. After a long time thinking, Xiao A concludes that this is the Tower of Hanoi. Moving takes time, so he must brew a longevity potion to complete the task. Now, he asks you to tell him how many steps are needed, so that he can brew enough potion.

Input Format

A single integer nn, the number of disks.

Output Format

A single integer ss, the number of steps required.

31
2147483647
15
32767

Hint

Constraints

For all testdata, n15000n \le 15000.

Translated by ChatGPT 5