HDU 2044

HDU 2044

Thinking

We must first understand the \ (A \) to \ (B \) , and the \ (a + n \) to \ (b + n \) is the same as the number of programs is

The first \ (n-\) hives only by the first \ (n-1 \) hives and \ (n-2 \) hives transfer over.

\(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;
}

Guess you like

Origin www.cnblogs.com/lukelmouse/p/12302082.html