题目地址:​​点击打开链接​

思路:水题,和上楼梯一个道理

#include <iostream>

using namespace std;

int main()
{
long long a[50] = {0,1,2};
int n,x,y,i;
for(i=3; i<50; i++)
{
a[i] = a[i-1] + a[i-2];
}
cin>>n;
while(n--)
{
cin>>x>>y;
cout<<a[y-x]<<endl;
}
return 0;
}


AC代码: