爬楼梯

来源:互联网 发布:淘宝客建站视频教程 编辑:程序博客网 时间:2024/04/30 08:59

爬楼梯

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

24

Example Output

25

Hint

 

Author

 

其实跟骨牌铺方格那道题一样。。。。就是换了个问法。
01#include<stdio.h>
02int main()
03{
04    int i, n;
05    long long f[51];
06    f[1] = 1;
07    f[2] = 2;
08    for(i = 3; i <= 50; i++)
09        f[i] = f[i - 1] + f[i -2];
10    while(scanf("%d", &n) != EOF)
11    {
12        printf("%lld\n", f[n]);
13    }
14    return 0;
15}

0 0
原创粉丝点击