zoukankan      html  css  js  c++  java
  • HDU 2041:超级楼梯

    超级楼梯

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 43689    Accepted Submission(s): 22327


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

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

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

    Sample Input
    2 2 3
     

    Sample Output
    1 2
     

    Author
    lcy
     

    Source
     

    Recommend
    lcy   |   We have carefully selected several similar problems for you:  2044 2045 2046 2018 2050 
     

    你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

    #include<iostream>
    using namespace std;
    int main()
    {
        int n;
        int a[45]= {1,2};
        for(int i=2; i<42; i++)
            a[i]=a[i-1]+a[i-2];
        cin>>n;
        while(n--)
        {
            int b;
            cin>>b;
            cout<<a[b-2]<<endl;
        }
    }
    

  • 相关阅读:
    AMBA总线介绍
    placeholder不显示的解决办法(支持ie8以上)
    通过新浪微博API获取数据
    PHP时间运算
    PHP队列
    stream_context_create()
    http_build_query()
    shuffle()
    session_id()
    session_name()
  • 原文地址:https://www.cnblogs.com/im0qianqian/p/5989608.html
Copyright © 2011-2022 走看看