#P5907. 数列求和加强版 / SPOJ MOON4

数列求和加强版 / SPOJ MOON4

Description

Given nn, aa, and kk, compute:

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

Output the answer modulo 998244353998244353.

Input Format

Input one line with three positive integers nn, aa, and kk.

Output Format

Output one line with one integer representing the answer.

6 4 3
1030980
233333333 114514 1919810
3191086

Hint

Constraints
For 20%20\% of the testdata, 1n,k1051\le n,k \le 10^5.
For 100%100\% of the testdata, 1k1071\le k \le 10^7, 1n,a9982443521\le n,a \le 998244352.

Translated by ChatGPT 5