题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2044
//C++代码
#include<iostream>
using namespace std;
int main(){
int n,a,b,i;
long long f[49];
f[1]=1,f[2]=2;
for(i=3;i<=48;i++) f[i]=f[i-1]+f[i-2];
cin>>n;
while(n--){
cin>>a>>b;
cout<<f[b-a]<<endl;
}
return 0;
}
本文提供了一种使用C++解决HDU 2044问题的方法,该问题涉及计算特定范围内的斐波那契数列值。通过预先计算并存储斐波那契数列,可以有效地处理多次查询。
2830

被折叠的 条评论
为什么被折叠?



