假设一段楼梯共n(n>1)个台阶,小朋友一步最多能上3个台阶,那么小朋友上这段楼梯一共有多少种方法. (小朋友真的累,我选择电梯) 大体思路用到了递归,假如说楼梯有12阶,那么11阶时有只有一种上方 12阶的时候有两种上方 13阶的时候有4中上法,递归到第一阶,第二阶 第三阶 n = int(input()) a = 1#第一层台阶只有一种上法 b = 2#第二层台阶有两种上法 c = 4#第三层台阶有4中上法 for i in range(n-3): m=a+b+c a=b
题目 On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the ste