0
点赞
收藏
分享

微信扫一扫

hdu2044 一只小蜜蜂.


思路:观察一下可以知道,比如走到7,首先要走到5或者6,要走到5,首先要先走到4或3...递推一下即可



#include<iostream>
#include<cstdio>
using namespace std;
#define LL long long
LL f[60];
int n;
int main()
{
   int T;
   scanf("%d",&T);
   f[0]=1;
   f[1]=1;
   for (int i = 2;i<51;i++)
	   f[i]=f[i-1]+f[i-2];
   while (T--)
   {
	   int a,b;
	   scanf("%d%d",&a,&b);
	   printf("%lld\n",f[b-a]);
   }
}




Description



有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。 

其中,蜂房的结构如下所示。 




 


Input


输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)。 


 


Output


对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。 


 


Sample Input


2 1 2 3 6


 


Sample Output


1 3


 





举报

相关推荐

0 条评论