Score: 1000 points
Problem Statement
Find the number of sequences of N non-negative integers A1,A2,...,AN that satisfy the following conditions:
- L≤A1+A2+...+AN≤R
- When the N elements are sorted in non-increasing order, the M-th and (M+1)-th elements are equal.
Since the answer can be enormous, print it modulo 109+7.
Constraints
- All values in input are integers.
- 1≤M<N≤3×105
- 1≤L≤R≤3×105
Input is given from Standard Input in the following format:
N M L R
Output
Print the number of sequences of N non-negative integers, modulo 109+7.
The sequences of non-negative integers that satisfy the conditions are:
(1,1,1,0),(1,1,1,1),(2,1,1,0),(2,1,1,1),(2,2,2,0),(2,2,2,1),(3,0,0,0),(3,1,1,0),(3,1,1,1),(3,2,2,0),(4,0,0,0),(4,1,1,0),(4,1,1,1),(5,0,0,0),(5,1,1,0),(6,0,0,0),(7,0,0,0)
and their permutations, for a total of 105 sequences.
The three sequences that satisfy the conditions are (2,2), (3,3), and (4,4).