A little bee ...

Source: Internet
Author: User

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) Total Submission (s): 47766 Accepted Submission (s): 17402


Problem description A trained bee can only crawl to the right side of the hive and cannot crawl backwards. Please program the number of possible routes that bees crawl from hive A to hive B.
Among them, the structure of the hive is shown below.


The first line of input data is an integer n, representing the number of test instances, followed by n rows of data, each containing two integers a and B (0<a<b<50).

Output for each test instance, print the number of possible routes that the bee crawls from hive A to hive B, with the output of each instance one row.

Sample Input
21 23 6

Sample Output
13



#include <stdio.h>

Main ()
{
int a,b,i,j,n;
__int64 x[1000];
scanf ("%d", &n);
while (n--)
{
scanf ("%d%d", &a,&b);
X[1]=1;
x[2]=2;
for (i=3;i<=50;i++)
X[I]=X[I-1]+X[I-2];
printf ("%i64d\n", x[b-a]);
}
return 0;
}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

A little bee ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.