#P5591. 小猪佩奇学数学

小猪佩奇学数学

Description

Peppa and George are learning math.

Given n,p,kn, p, k, compute

$$\sum_{i=0}^n \binom n i \times p^{i} \times \left\lfloor \frac{i}{k} \right\rfloor \bmod 998244353$$

Input Format

Three positive integers, representing n,p,kn, p, k.

Output Format

One positive integer, representing the answer.

3 3 2
54

Hint

For 20%20\% of the testdata, 1n1061 \leq n \leq 10^6.

For another 40%40\% of the testdata, k{2w0w10}k \in \{2^w|0 \leq w \leq 10\}.

For 100%100\% of the testdata, 1n,p<9982443531 \leq n, p < 998244353, and k{2w0w20}k \in \{2^{w}|0 \leq w \leq 20\}.

A Friendly Reminder from the Problem Setter

Please pay attention to the impact of constant factors on your program’s efficiency.

Translated by ChatGPT 5