Power Sum
Time limit2sMemory limit128 MB
Compute 1^K + 2^K + ... + N^K modulo 1,000,000,007 for N up to 10^9 and K up to 50.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics, Number theory
- Solved
- No attempts yet
Problem
Given positive integers N and K, compute the following value modulo 1,000,000,007.
1^K + 2^K + 3^K + ... + N^K
Input
The first line contains two positive integers, N and K. N is at most 10^9, and K is at most 50.
Output
Print the remainder of 1^K + 2^K + 3^K + ... + N^K divided by 1,000,000,007.