HDOJ_2044_大二写_一只小蜜蜂...

AC代码:

//2044
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    freopen("in.txt","r",stdin);
    int N;
    scanf("%d",&N);
    while(N--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        long long sum,sum1 = 1,sum2 = 2;
        if(b == (a+1))
            sum=sum1;
        else if(b == (a+2))
            sum=sum2;
        else
        {
            for(int i=a+3;i<=b;i++)
            {
                sum=sum1+sum2;
                sum1=sum2;
                sum2=sum;
            }
        }        
        
        printf("%lld\n",sum);
    }
    
    fclose(stdin);
    return 0;
}

 

posted @ 2018-11-10 08:57  pha创噬  阅读(101)  评论(0编辑  收藏  举报