一只小蜜蜂...

一只小蜜蜂...

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 20   Accepted Submission(s) : 13

Font: Times New Roman | Verdana | Georgia

Font Size:

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

Author

lcy

Source

递推求解专题练习(For Beginner)
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    __int64 max[60];
    max[0]=1;
    max[1]=2;
    for(int i=2;i<51;i++)
    {
        max[i]=max[i-1]+max[i-2];
    
    
    }
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int k=0;k<n;k++)
        {
            cin>>a>>b;
            printf("%I64d
",max[b-a-1]);
            
        
        
        }
    
    
    }




 return 0;
}

原文地址:https://www.cnblogs.com/2013lzm/p/3254689.html