标签:++ its inline math while name include namespace ons
首先要明白从 \(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;
}
标签:++ its inline math while name include namespace ons
原文地址:https://www.cnblogs.com/lukelmouse/p/12302082.html