luogu#P4948. 数列求和

数列求和

Problem Description

Given n,a,kn, a, k, compute:

i=1nikai\sum_{i=1}^n i^k a^i

Output the answer modulo 109+710^9 + 7.

Input Format

Input one line with three non-negative integers n,a,kn, a, k. Here n,a1n, a \ge 1.

Output Format

Output one line with one integer representing the answer.

3 4 0
84
3 10 1
3210
3 9 2
6894

Hint

Test Point ID n=n= k=k=
11 10610^6 10310^3
22 2×1032\times 10^3
33 101810^{18} 00
44 11
5,65,6 22
7,87,8 10310^3
9,109,10 2×1032\times 10^3

For 100%100\% of the testdata, n1018n \le 10^{18}, a109a \le 10^9, and k2000k \le 2000.

Translated by ChatGPT 5