HDU 2044

HDU 2044

思路

首先要明白从 \(a\)\(b\) 和 从\(a+n\)\(b +n\)的方案数是一样的

\(n\) 个蜂房只能由第\(n-1\)个蜂房和第\(n-2\) 个蜂房转移过来。

\(f[n]=f[n-1]+f[n-2]\)

#include <bits/stdc++.h>
using namespace std;
const int N = 100;
typedef long long LL;
LL f[N] = {0,1,1,2},k = 3;
int main() {
    int n,a,b;
    cin >> n;
    for(int i = 0;i < n; ++i) {
        cin >> a >> b;
        int t = b - a + 1;
        if(t > k) {
            while(k <= t) {
                k ++;
                f[k] = f[k - 1] + f[k - 2];
            }
        }
        cout << f[t] << endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lukelmouse/p/12302082.html
今日推荐