爬楼梯 (sdut oj)
来源:互联网 发布:galgame制作软件 编辑:程序博客网 时间:2024/05/17 08:26
爬楼梯
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
小明是个非常无聊的人,他每天都会思考一些奇怪的问题,比如爬楼梯的时候,他就会想,如果每次可以上一级台阶或者两级台阶,那么上 n 级台阶一共有多少种方案?
Input
输入包含多组测试数据,对于每组测试数据:
输入只有一行为一个正整数 n(1 ≤ n ≤ 50)。
Output
对于每组测试数据,输出符合条件的方案数。
注意:64-bit 整型请使用 long long 来定义,并且使用 %lld 或 cin、cout 来输入输出,请不要使用 __int64 和 %I64d。
Example Input
24
Example Output
25
Hint
Author
参考代码
#include<stdio.h>int main(){ int i,n; int long long a[50]; a[0] = 1; a[1] = 2; while(~scanf("%d",&n)) { for( i = 2; i < n; i++ ) { a[i] = a[i-1] + a[i-2]; } printf("%lld\n",a[n-1]); } return 0;}
0 0
- 爬楼梯 (sdut oj)
- SDUT OJ 走楼梯
- SDUT 爬楼梯
- LeetCode OJ 之 Climbing Stairs ( 爬楼梯 )
- 第12周OJ实践 爬楼梯
- LeetCode OJ-70. Climbing Stairs(爬楼梯问题)
- Leet Code OJ 70. Climbing Stairs(爬楼梯问题)
- SDUT OJ 2718
- SDUT OJ -2892 A
- SDUT OJ-2896
- SDUT OJ 2862 勾股定理
- SDUT OJ 走迷宫
- SDUT OJ 2399 Palindrome
- SDUT oj 玲珑龟
- 二叉排序树 (sdut oj 2482)
- SDUT oj 二叉排序树
- SDUT OJ 3374
- 小鑫追女神 (sdut oj)
- UIScrollView 实践经验
- 为安卓应用添加手势密码功能,遇到的一些问题以及解决方法
- MySQL源码学习:InnoDB的ib_logfile写入策略
- 运放使用“虚短”和”虚断“的理解
- 算法设计与分析
- 爬楼梯 (sdut oj)
- 用数组构造一个二叉树
- You need to use a Theme.AppCompat theme (or descendant) with this activity.异常处理其一
- 0313 JS
- Dex文件格式扫描器:特征API的检测和扫描(小工具一枚)
- OpenSSH升级到7.0+遇到的问题
- SVN trunk branches tag详解
- Thread的中断机制(interrupt)
- FZU