Number of ways in a range

0

0 votes
Linear Algebra, Hard, Recruit, Approved, Grammar-Verified, Mathematics, Matrix Exponentiation
Problem

You are given three integers, namely L, R, and X, where X varies from [L,R].

Write a program to find the sum of the number of ways in which X people are chosen. If you choose a personi (1iX), then you cannot choose its neighboring person.

Input format

  • First line: T (number of test cases)
  • First line in each test case: Two space-separated integers L and R

Output format

For each test case, print the sum of the number of ways modulo 109+7 in which X people are chosen, where if you choose a personi (1iX), you can choose one or none of its immediate neighbors, but not both.

Constraints

1T103
1LR109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Case 1: If number of person is 1, you can either choose it or not choose it. 2 ways.

Editor Image

?