Sum of Powers 1
Time limit1sMemory limit512 MB
Given n and p, compute the sum of k^p for k from 1 to n, modulo 10^9+7, where n is up to 1e9 and p is up to 1000.
- Level
Medium6 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
Find the sum of the -th powers of all natural numbers from 1 to , modulo . In other words, compute the following value.
Input
The first line contains and , separated by a space.
Output
Print the sum of the powers modulo .