标签:blog http io ar os sp for 数据 div
有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法?
注:规定从一级到一级有0种走法。
2 2 3
1 2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;
int t,n,f[45];
void dp()
{
for(int i=4;i<=45;i++)
f[i]=f[i-1]+f[i-2];
}
int main()
{
scanf("%d",&t);
f[1]=0;
f[2]=1;
f[3]=2;
dp();
for(int k=1;k<=t;k++)
{
scanf("%d",&n);
printf("%d\n",f[n]);
}
return 0;
}
标签:blog http io ar os sp for 数据 div
原文地址:http://www.cnblogs.com/a972290869/p/4099965.html