题目描述
Problem Description
The hospitable Little Monkey invites friends from the forest to dinner. His friends are numbered from $1$ to $N$. Each friend brings him some gifts: Big Bananas. The first friend brings him $1$ Big Banana, and each subsequent friend brings the total number of gifts from all previous friends plus his own number raised to the power of $K$. For example, if $K=2$, the number of gifts from the first few friends would be:
$1, 5, 15, 37, 83, \ldots$
If $K=3$, the number of gifts from the first few friends would be:
$1, 9, 37, 111, \ldots$
Now, Little Monkey is curious about how many gifts he will receive from the $N$-th friend and asks for your help.
Given $N$ and $K$, output the number of gifts the $N$-th friend will bring, modulo $10^9+7$.
Input Format
The first line contains two integers $N$ and $K$.
Output Format
Output a single integer, which is the number of gifts the $N$-th friend will bring, modulo $10^9+7$.
Sample Input and Output
Sample Input #1
4 2
Sample Output #1
37
Sample Input #2
2333333 2
Sample Output #2
514898185
Sample Input #3
1234567890000 3
Sample Output #3
891659731
Sample Input #4
66666666 10
Sample Output #4
32306309
Notes
- $20\%$ of the test cases: $N \le 10^6$;
- Another $10\%$ of the test cases: $K=1$;
- Another $20\%$ of the test cases: $K=2$;
- Another $20\%$ of the test cases: $K=3$;
- $100\%$ of the test cases: $N \le 10^{18}$, $K \le 10$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分