hdoj 2041 超级阶梯

代码:

#include <stdio.h>
int main()
{
int n;
int i;
int m;
int count;
int dp[50];
while(scanf("%d",&n)!=EOF)
{
dp[1]=1;
dp[2]=1;
dp[3]=2;
while(n--)
{
count=0;
scanf("%d",&m);
for(i=4; i<=m; i++)
{
dp[i]=dp[i-1]+dp[i-2];
}
printf("%d ",dp[m]);
}
}
return 0;
}

运用递推到达第i阶梯的方法数dp[i]=dp[i-1]+dp[i-2];

原文地址:https://www.cnblogs.com/weiyikang/p/3870075.html