You are climbing a stair case. It takes n steps 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?

Note: Given n will be a positive integer.

Example 1:

Input: 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps

Example 2:

Input: 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
 class Solution {
public:
int climbStairs(int n) {
if(n == )
return ; int res[n + ];
res[] = ;
res[] = ;
for(int i = ; i <= n; i++)
res[i] = res[i - ] + res[i - ];
return res[n];
}
};

最新文章

  1. Easymake
  2. PHP实现执行定时任务的几种思路详解
  3. bootstrap datetimepicker 中只显示年或者只显示月份
  4. 调试技巧--Windows端口号是否被占用
  5. windows上修改路由表
  6. 容易网CEO陈从容:用分享成就生活之美
  7. APUE学习总结
  8. android获得屏幕高度和宽度(display中getSize(Point)方法使用)
  9. 设置TrackMouseEvent捕获WM_MOUSEHOVER和WM_MOUSELEAVE消息
  10. NYOJ15-括号匹配(二)-区间DP
  11. spring源码系列(一)sring源码编译 spring源码下载 spring源码阅读
  12. md5加密utils
  13. MUD 多人地下城
  14. PHP创建socket服务
  15. RabbitMQ 安装与使用
  16. 南理第八届校赛同步赛-C count_prime//容斥原理
  17. 【组合&amp;取补集】数三角形 @CQOI2014/BZOJ3505/upcexam3843
  18. PCA降维实验代码
  19. Linux rhel7 下MySQL5.7.18详细安装文档
  20. Java 默认事务级别read committed对binlog_format的需求

热门文章

  1. Centos安装VMware
  2. java类的初始化程序块以及被实例化时候的执行顺序
  3. js标准对象——Date
  4. spring入门(四) spring mvc返回json结果
  5. c#数据库连接池Hikari重构升级
  6. Sonar安装-Linux[20171227]
  7. Dockerfile中npm中Error: could not get uid/gid问题的解决方法
  8. js 关于字符串转数字及数字保留位数的控制
  9. dom4j支持Xpath的具体操作
  10. springmvc重定向请求。