第39级台阶
来源:互联网 发布:win10怎么连接usb网络 编辑:程序博客网 时间:2024/05/16 07:49
小明刚刚看完电影《第39级台阶》,离开电影院的时候,他数了数礼堂前的台阶数,恰好是39级!
站在台阶前,他突然又想着一个问题:
站在台阶前,他突然又想着一个问题:
如果我每一步只能迈上1个或2个台阶。先迈左脚,然后左右交替,最后一步是迈右脚,也就是说一共要走偶数步。那么,上完39级台阶,有多少种不同的上法呢?
public class test4_a_c {static int r =0;public static void fun(int sum,int step){if(sum>39)//注意考虑这种情况return;if(sum==39){if(step%2==0){r++;}return;}else{fun(sum+1,step+1);fun(sum+2,step+1);}}public static void main(String[] args) {fun(0,0);System.out.println(r);}}
0 0
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 第39级台阶
- 写微信小程序所感
- Android组件系列----Activity组件详解
- 016带关闭按钮的右下角图片广告
- zxing扫码工具相机变形解决方法
- Android编程权威指南之使用RecyclerView显示列表
- 第39级台阶
- WebBroker 后端输出页面到浏览器,让浏览器做 URL 跳转
- 代码整洁之道精华——第十一章 系统
- ORA-00257: archiver error. Connect internal only, until freed.处理办法(亲测可行)
- Android 使用MVP Rxjava2+Retrofit2+Dagger2写的一个登录注册(含后台+数据库)的demo
- float数值update逼近目标数值算法
- ArcGIS插件开发中跨窗体数据访问( AddIn.FromID)
- 李宏毅机器学习课程笔记3:Backpropagation、"Hello world" of Deep Learning、Tips for Training DNN
- 【新手经验分享】有关MYSQL和JDBC应用中的一些问题整合