1160 : Sum Them
Time Limit: 1 Sec Memory Limit: 128 MB Submitted: 1391 Solved: 421Description
Given n and m, calculate the sum of the incremental multiplication formulas:
$$ f(n, m)=\sum_{i=1}^{n}\prod_{j=i}^{i+m-1}j $$
Input
No more than 50 test cases. Each case one line, including integer n and m.
1 ≤ n, m ≤ 106.
Output
For each test case, output the result of f(n, m) modulo 109 + 7.
Sample
2 2 98 3
8 24497550
Hint
Author
CSGrandeur