トヨタシステムズプログラミングコンテスト2022(AtCoder Beginner Contest 279)
G
At Most 2 Colors
AtCoder
⌀ 2431
原题
← Ex→
翻译中…

Problem Statement

翻译中…

There is a grid with $1 \times N$ squares, numbered $1,2,\dots,N$ from left to right.

翻译中…

Takahashi prepared paints of $C$ colors and painted each square in one of the $C$ colors. Then, there were at most two colors in any consecutive $K$ squares. Formally, for every integer $i$ such that $1 \le i \le N-K+1$, there were at most two colors in squares $i,i+1,\dots,i+K-1$.

翻译中…

In how many ways could Takahashi paint the squares? Since this number can be enormous, find it modulo $998244353$.

翻译中…

Constraints

翻译中…
  • All values in the input are integers.
  • $2 \le K \le N \le 10^6$
  • $1 \le C \le 10^9$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N K C

翻译中…

Output

翻译中…

Print the answer as an integer.

翻译中…

样例

Input #1
3 3 3
Output #1
21
In this input, we have a $1 \times 3$ grid. Among the $27$ ways to paint the squares, there are $6$ ways to paint all squares in different colors, and the remaining $21$ ways are such that there are at most two colors in any consecutive three squares.
Input #2
10 5 2
Output #2
1024
Since $C=2$, no matter how the squares are painted, there are at most two colors in any consecutive $K$ squares.
Input #3
998 244 353
Output #3
952364159
Print the number modulo $998244353$.
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。