http://acm.hdu.edu.cn/showproblem.php?pid=2044
有一只蜜蜂只会往右爬。。
#include <iostream>
using namespace std;
#define N 55
__int64 cell[N];
void init(){
int i;
cell[0]=0;
cell[1]=1;
for (i=2;i<N;i++)
cell[i]=cell[i-1]+cell[i-2];
}
int main(){
int n,a,b;
scanf("%d",&n);
init();
while (n--){
scanf("%d%d",&a,&b);
printf("%I64d\n",cell[b-a+1]);
}
return 0;
}
本文介绍了一种解决蜜蜂从起点到终点爬行路径问题的算法。通过预先计算蜜蜂可能爬行的所有路径,并使用动态规划的方法优化计算过程,提高了算法效率。
276

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



