超级楼梯

http://10.12.162.1:5880/contest/4/problem/P0203
有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?

#include<iostream>
using namespace std;
int main(){
    long long res[41];
    res[1]=1;
    res[2]=1;
    for(int i = 3;i<=40;i++)
    {
        res[i] = res[i-1] + res[i-2];
    }
    int n, t;
    cin>>n;
  	res[1]=0;
    while(n--)
    {
      	scanf("%d",&t);
        //cin>>t;
     	printf("%lld
",res[t]);
       //cout<<res[t]<<endl;		//大量输入输出-->使用cin  cout超时
    }
    return 0;
}
原文地址:https://www.cnblogs.com/CSE-kun/p/13938531.html