您的位置:首页 > 其它

HDOJ  2041   超级楼梯

2015-12-18 18:12 169 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2041

题目是一个递退题,用前两种状态,来表示现在的状态,,,

关系式:f(n)=f(n-1)+f(n-2);

#include <stdio.h>

int main()

{

int
n,t;

int
i,a[45];


a[0]=a[1]=1;


for(i=2;i<45;i++)


a[i]=a[i-1]+a[i-2];


scanf("%d",&t);


while(t--)


scanf("%d",&n),printf("%d\n",a[n-1]);

return
0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: