标签:水题
推公式得出斐波那契数列
#include<stdio.h> __int64 dp[60]; int main(){ int n; #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int a,b,T; scanf("%d",&T); while(T--){ scanf("%d%d",&a,&b); if(a>b){ printf("0\n"); continue; } dp[a]=1; dp[a-1]=0; for(int i=a+1;i<=b;i++) dp[i]=dp[i-1]+dp[i-2]; printf("%I64d\n",dp[b]); } return 0; }
超级楼梯一样的:
#include<stdio.h> __int64 dp[60]; int main(){ int n; #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int a,b,T; scanf("%d",&T); while(T--){ scanf("%d",&b); a=1; dp[a]=1; dp[a-1]=0; for(int i=a+1;i<=b;i++) dp[i]=dp[i-1]+dp[i-2]; printf("%I64d\n",dp[b]); } return 0; }
HDU 2044 一只小蜜蜂... HDU 2041 超级楼梯
标签:水题
原文地址:http://blog.csdn.net/lj94093/article/details/45126117