403359: GYM101138 G LCM-er
Memory Limit:0 MB
Time Limit:0 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
G. LCM-ertime limit per test0.5 секундmemory limit per test256 мегабайтinputstandard inputoutputstandard output
You are given four integers n, a, b and x. Your task is to count modulo 109 + 7 the number of sequences of integers A satisfying the following conditions:
- A should contain exactly n elements.
- a ≤ A1 ≤ A2 ≤ ... ≤ An ≤ b (the sequence is non-decreasing and all integers are between a and b, inclusive).
- The least common multiple of all numbers in A should be divisible by x.
The only line of the input contains four integers n, a, b and x (1 ≤ n ≤ 100, 1 ≤ a, b, x ≤ 109, a ≤ b).
OutputCount sequences of integers satisfying the given conditions. Print the answer modulo 109 + 7.
ExamplesInput2 1 7 6Output
9Input
1 1 50 7Output
7
In the first sample there are 9 valid sequences: (1, 6), (2, 3), (2, 6), (3, 4), (3, 6), (4, 6), (5, 6), (6, 6), (6, 7).