爬楼梯
来源:互联网 发布:招商银行mac控件下载 编辑:程序博客网 时间:2024/04/30 14:22
爬楼梯
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
小明是个非常无聊的人,他每天都会思考一些奇怪的问题,比如爬楼梯的时候,他就会想,如果每次可以上一级台阶或者两级台阶,那么上 n 级台阶一共有多少种方案?
Input
输入包含多组测试数据,对于每组测试数据:
输入只有一行为一个正整数 n(1 ≤ n ≤ 50)。
Output
对于每组测试数据,输出符合条件的方案数。
注意:64-bit 整型请使用 long long 来定义,并且使用 %lld 或 cin、cout 来输入输出,请不要使用 __int64 和 %I64d。
Example Input
2
4
Example Output
2
5
#include <stdio.h>int main(){ int n,i; long long int a[60]={0}; while(~scanf("%d",&n)) { for(i=1;i<=3;i++) { a[i]=i; } if(n<=3) { printf("%d\n",a[n]); } else { for(i=4;i<=n;i++) { a[i]=a[i-1]+a[i-2]; } printf("%lld\n",a[n]); } }}
0 0
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 空间域图像增强
- 链表反序
- vue入门实战教程 - 用vue高仿饿了吗APP
- PopupWindow其中的view获取焦点?
- POJ 3293 Rectilinear polygon 已翻译
- 爬楼梯
- hdu5115 Dire Wolf 区间dp
- Java泛型(Generics)
- python从零到一
- 【spring】 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")?
- 2、Power Query-动态汇总单元格区域数据
- 屏幕适配之dp转px?
- Count and Say