题解 | #吃糖果#
吃糖果
https://www.nowcoder.com/practice/72015680c32b449899e81f1470836097
n = int(input()) ans = [1, 2] for _ in range(3, n+1): ans[0], ans[1] = ans[1], ans[0]+ans[1] if n == 1: print(1) else: print(ans[-1])
斐波那契数列
吃糖果
https://www.nowcoder.com/practice/72015680c32b449899e81f1470836097
n = int(input()) ans = [1, 2] for _ in range(3, n+1): ans[0], ans[1] = ans[1], ans[0]+ans[1] if n == 1: print(1) else: print(ans[-1])
斐波那契数列
相关推荐