小蜜蜂(递归)

一只小蜜蜂...

Problem 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
 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     long long  a[52];
 7     int i;
 8     a[1]=1,a[2]=2;
 9     for(i=3;i<51;i++)
10         a[i]=a[i-1]+a[i-2];
11     int T;
12     int c,d;
13     cin>>T;
14     while(T--)
15     {
16         cin>>c>>d;
17         cout<<a[d-c]<<endl;
18     }
19 }
原文地址:https://www.cnblogs.com/a1225234/p/4550047.html