Title: There is a trained bees can only be climbed right adjacent hive, not the reverse crawl. Calculation program a number of possible routes to climb bee hive from hive b a.
Wherein the honeycomb structure shown below.
Input
first line of input data N is an integer, indicates the number of test cases, then the N rows, each row comprising two integers a and b (0 <a <b < 50).
Output
For each test case, output a number of possible routes to climb the bees from hive hive b a, the output of each row for instance.
Solution: the path to each cell of the two paths is always obtained by adding the numbers to the left, the path across a number 1, 2 across two behind continued addition, to consider adding recursion
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
int a, b, n;
cin >> n;
while (n--)
{
cin >> a >> b;
int c = b - a;
long long a[50] = { 0,1,2 };
for (int i = 3; i <= 50; i++)
{
a[i] = a[i - 1] + a[i - 2];
}
cout << a[c] << endl;
}
return 0;
}