http://acm.hdu.edu.cn/showproblem.php?pid=2041
有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?
#include<iostream>
#include<cmath>
using namespace std;
int a[45];
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int T;cin>>T;
while(T--){
int n;
cin>>n;
a[1]=1;
a[2]=1;
for(int i=3;i<=n;i++){
a[i]=a[i-1]+a[i-2];
}
cout<<a[n]<<endl;
}
return 0;
}