• 杭电 2041 超级楼梯


    Description

    有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?
     

    Input

    输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。
     

    Output

    对于每个测试实例,请输出不同走法的数量
     

    Sample Input

    2
    2
    3
     

    Sample Output

    1
    2
     1 #include<cstdio> 
     2 __int64 a[55]={0,1,1,2};
     3 int  main()
     4 {
     5     int t;
     6     scanf("%d",&t);
     7     for(int i = 4; i <= 50; i++)
     8     {
     9         a[i]=a[i-1]+a[i-2];
    10     }
    11     while(t--)
    12     {
    13         int n;
    14         scanf("%d",&n);
    15         printf("%I64d
    ",a[n]);
    16     }
    17 }
     1 #include<cstdio> 
     2 int a[50]={0,1,1,2};
     3 int  main()
     4 {
     5     int t;
     6     scanf("%d",&t);
     7     while(t--)
     8     {
     9         int n;
    10         scanf("%d",&n);
    11         for(int i = 4; i <= n; i++)
    12         {
    13             a[i]=a[i-1]+a[i-2];
    14         }
    15         printf("%d
    ",a[n]);
    16     }
    17 }
     
    ——将来的你会感谢现在努力的自己。
  • 相关阅读:
    求给定数里的数的质数最大——pku3048
    poj1106
    poj1450
    poj1094
    poj1111
    poj1120
    C#.NET学习笔记 类,接口,对象
    在Repeater中嵌套使用Repeater
    数据表分区解决方案(转)
    C#小数点格式化
  • 原文地址:https://www.cnblogs.com/yexiaozi/p/5690432.html
Copyright © 2020-2023  润新知