不得不说,python对于大整数的运算真的太方便了!(不用绞尽脑汁去搞大整数的输出= =)
汉诺塔的原理就是递归,百度都能找到资料,这里直接放代码
https://www.dotcpp.com/oj/problem1109.html
AC代码(比C慢、内存耗大)
# -*- coding: utf-8 -*-
def h(x):
if x==1:
return 2
else:
return 2+2*h(x-1)
print(h(int(input())))