思路:本质与斐波那契数列一样,关键在于a与b之差
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<long long> nums(51);
nums[0] = 0;
nums[1] = 1;
nums[2] = 2;
for (int i = 3; i < 51; i++) {
nums[i] = nums[i - 1] + nums[i - 2];
}
int n, a, b;
cin >> n;
while (n--) {
cin >> a >> b;
cout << nums[b - a] << endl;
}
return 0;
}