Problem8971--[ysupo] $\sum_{i=0}^{n-1} r^i i^d$

8971: [ysupo] $\sum_{i=0}^{n-1} r^i i^d$

[Creator : ]
Time Limit : 2.000 sec  Memory Limit : 512 MiB

Description

Given integers $r$, $d$ and $n$, calculate $\sum_{i=0}^{n-1} r^i i^d$ modulo $998244353$.
We define $0^0 = 1$.

Input

$r$ $d$ $n$

Output

$\mathit{answer}$

Constraints

$0 \le r <998244353$
$0 \le d \le 10^7$
$0 \le n \le 10^{18}$

Sample 1 Input

2 5 8

Sample 1 Output

2767418

HINT

相同题目:Yosupo

Source/Category