摘要: Q : You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?A: 动态规划的题。记f(n)是爬n steps stair的不同方式。爬到n层,那么有两种选择:1. 先爬n-1层,再往上1step2. 先爬n-2层,再往上2 steps。那么f(n) = f(n-2) + f(n-1) (Fibonacci数) 注意不要用递归, 阅读全文
posted @ 2013-06-11 15:52 summer_zhou 阅读(149) 评论(0) 推荐(0)