- 1#include 2 using namespace std;
- 3 long long path(int a, int b) 4 {
- 5
- if (b <= a + 1) 6
- return 1;
- 7
- else 8 {
- 9 long long l1 = 1,
- l2 = 1;
- 10 int a1 = a + 2;
- 11 long long sum = 0;
- 12
- while (a1 <= b) 13 {
- 14 sum = l1 + l2;
- 15 l1 = l2;
- 16 l2 = sum;
- 17 a1++;
- 18
- }
- 19
- return l2;
- 20
- }
- 21
- }
- 22 int main() 23 {
- 24 int n;
- 25 cin >> n;
- 26
- while (n) 27 {
- 28 int a,
- b;
- 29 cin >> a >> b;
- 30 cout << path(a, b) << endl;
- 31 n--;
- 32
- }
- 33 //system("pause");
- 34
- return 0;
- 35
- }
来源: http://www.bubuko.com/infodetail-2086033.html