Sum of Powers 2
Time limit5sMemory limit512 MB
For each query with a, b, and d, compute the sum of k^d for k from a to b, modulo 10^9+7.
- Level
Medium7 of 10
- Topics
- Math, Prefix sum, Number theory
- Solved
- No attempts yet
Problem
Write a program that answers the following queries over lines.
- : Print the value of .
Input
The first line contains the number of queries .
Each of the next lines contains one query from the problem, one per line.
Output
Print the answer to each query on its own line, in the same order as the input.
Constraints
All numbers in the input are integers.
, ,
The sum of over all queries does not exceed .