HDU 2044 一只小蜜蜂...

题解:将m与n相减,又回到超级楼梯这道题。

#include <cstdio>

#include <iostream>

using namespace std;

long long f[50];

int main()

{

    int i,t;

    f[1]=1; f[2]=2;

    for(int i=3; i<50; i++)

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

    scanf("%d",&t);

    while(t--)

    {

        int n,m;

        scanf("%d%d",&n,&m);

        n=m-n;

        cout<<f[n]<<endl;

    }

    return 0;

}

 

注意:数据范围看清楚,注意检验是否超过int的范围。

  

你可能感兴趣的:(HDU)