HDU - 一只小蜜蜂 :递推

http://acm.hdu.edu.cn/showproblem.php?pid=2044

 

 

#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <assert.h>
#include <set>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <iostream>
#include <bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
const int mxn = 1e2+5;
ll n,m,k,t,dp[mxn],a[mxn];
int main()
{
    for(int i=1;i<55;i++)
        dp[i] = i<=3 ? i : dp[i-1]+dp[i-2] ;
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        cout<<dp[m-n]<<endl;
    }
    return 0 ;
}

 

posted @ 2020-02-01 15:02  __MEET  阅读(114)  评论(0编辑  收藏  举报