Problem:
Score : 500 points

Problem Statement

There are N blocks arranged in a row. Let us paint these blocks.

We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.

Find the number of ways to paint the blocks under the following conditions:

For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors.

There may be at most K pairs of adjacent blocks that are painted in the same color.

Since the count may be enormous, print it modulo 998244353.

Constraints

All values in input are integers.

1 \leq N, M \leq 2 \times 10^5

0 \leq K \leq N - 1

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the answer.

Sample Input 1

3 2 1

Sample Output 1

6

The following ways to paint the blocks satisfy the conditions: 112, 121, 122, 211, 212, and 221. Here, digits represent the colors of the blocks.

Sample Input 2

100 100 0

Sample Output 2

73074801

Sample Input 3

60522 114575 7559

Sample Output 3

479519525

Solution in Rust (1.42.0) (judge verdict: Accepted)

// ==============
const MAXN: usize = 300010;

struct Comb {
    fact: [usize; MAXN],
    finv: [usize; MAXN],
}
impl Comb {
    // これをメンバーに持たせるのは悩みどころさん
    fn p_mod(base: usize, exp: usize) -> usize {
        if exp != 0 {
            if (exp & 1) == 1 {
                Comb::p_mod(base * base % MOD, exp / 2) * (base) % MOD
            } else {
                Comb::p_mod(base * base % MOD, exp / 2)
            }
        } else {
            1
        }
    }

    fn fact_new() -> Self {
        let mut fact: [usize; MAXN] = [0; MAXN];
        fact[0] = 1;
        for i in 1..MAXN {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        let mut finv: [usize; MAXN] = [0; MAXN];
        finv[MAXN - 1] = Comb::p_mod(fact[MAXN - 1], MOD - 2);
        for i in (0..(MAXN - 1)).rev() {
            finv[i] = (finv[i + 1] * (i + 1)) % MOD;
        }
        Comb {
            fact: fact,
            finv: finv,
        }
    }
    fn nPr(&self, n: usize, r: usize) -> usize {
        if n < r || r == 0 {
            0
        } else {
            self.fact[n] * self.finv[n - r] % MOD
        }
    }
    fn nCr(&self, n: usize, r: usize) -> usize {
        if n < r {
            0
        } else if r == 0 {
            1
        } else {
            self.fact[n] * self.finv[r] % MOD * self.finv[n - r] % MOD
        }
    }
    fn nHr(&self, n: usize, r: usize) -> usize {
        if n == 0 && r == 0 {
            1
        } else {
            self.nCr(n + r - 1, r)
        }
    }
}
// ==============

fn main() {
    let (n, m, k): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let c = Comb::fact_new();
    let mut ans = 0;
    for kk in 0..k + 1 {
        ans += (m * c.nCr(n - 1, kk) % MOD) * Comb::p_mod(m - 1, n - 1 - kk) % MOD;
        ans %= MOD;
    }
    println!("{}", ans % MOD);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 998244353;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========