一只小蜜蜂…
Problem Description
有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。
其中,蜂房的结构如下所示。
Input
输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)(0<a<b<50)。
Output
对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。
Sample Input
2
1 2
3 6
Sample Output
1
3
*规律:a b
1->2 1 c[1]
1->3 2 c[2]
1->4 3 c[3]
1->5 5 c[4]
1->6 8 c[5]
1->7 13 c[6]
··········
··········
a->b c[b-a]*
#include<stdio.h>
#include<set>
#include<cstdio>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,a,b;
ll i,c[500];
c[1]=1;
c[2]=2;
for(i=3;i<=50;i++)
{
c[i]=c[i-1]+c[i-2]; //打表
}
scanf("%lld",&n);
while(n--)
{
scanf("%lld%lld",&a,&b); //a<b
printf("%lld\n",c[b-a]);
}
return 0;
}