#P5364. [SNOI2017] 礼物

[SNOI2017] 礼物

Description

The hospitable little monkey invites friends from the forest to dinner. His friends are numbered from 11 to NN. Each arriving friend will bring him some gifts: big bananas.

The first friend brings 11 big banana. After that, when each friend arrives, they will bring the total number of gifts brought by all previous friends, plus their own index raised to the KK-th power.

So, if K=2K=2, the numbers of gifts brought by the first few friends are:

1,5,15,37,83,1,5,15,37,83,\ldots

If K=3K=3, the numbers of gifts brought by the first few friends are:

1,9,37,111,1,9,37,111,\ldots

Now, the little monkey is curious about how many gifts he will receive from the NN-th friend, so he asks for your help.

Given NN and KK, output the number of gifts brought by the NN-th friend modulo 109+710^9+7.

Input Format

The first line contains two integers N,KN,K.

Output Format

Output one integer, representing the number of gifts brought by the NN-th friend modulo 109+710^9+7.

4 2
37
2333333 2
514898185
1234567890000 3
891659731
66666666 10
32306309

Hint

  • 20%20\% of the testdata: N106N \le 10^6.
  • Another 10%10\% of the testdata: K=1K=1.
  • Another 20%20\% of the testdata: K=2K=2.
  • Another 20%20\% of the testdata: K=3K=3.
  • 100%100\% of the testdata: N1018N \le 10^{18}, K10K \le 10.

Translated by ChatGPT 5