A little bee ...
http://acm.hdu.edu.cn/showproblem.php?pid=2044
Time limit:2000/1000 MS (java/others)
Memory limit:65536/32768 K (java/others)
Problem Description
A trained bee can only crawl to the adjacent hive on the right and not crawl in reverse. Please program the number of possible routes by which bees climb from hive A to hive B. The structure of the hive is shown below.
Input
The first line of input data is an integer n that represents the number of test instances, then n rows of data, each containing two integers a and B (0<a<b<50).
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45515.htm
Output
For each test instance, export the number of possible routes where the bee crawled from hive A to hive B, and the output of each instance occupies one row.
Sample Input
21 23 6
Sample Output
13
It's clear that lattice n can come from n-1 and n-2, so it's the Fibonacci relationship.
Notice that the a=1,b=49 is a super int, and you want to use long long.
Complete code:
/*0ms,208kb*/
#include <cstdio>
long long f[50];
int main ()
{
int T, a, B, I;
F[1] = f[2] = 1;
for (i = 3; i < ++i) f[i] = F[i-1] + f[i-2];
scanf ("%d", &t);
while (t--)
{
scanf ("%d%d", &a, &b);
printf ("%i64d\n", F[b-a + 1]);
return 0;
}