m = {} def f(x): if x == 1: return 2 if x == 2: return 3 if m.get(x, 0) != 0: return m[x] m[x] = f(x - 1) + f(x - 2) return m[x] print(f(int(input())))
斐波那契数列更快的解法:矩阵快速幂(逃