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 C# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;

namespace 水色コーダーに俺はなった{
    class Inonoa{
        
        static long[] fac = new long[200001];
        static long[] ifac = new long[200001];

        /* ここに書け */
        static void Main(){
            fac[0] = 1;
            ifac[0] = 1;
            for(long i=0;i<100000;i++){
                fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
                ifac[i+1] = ifac[i]*Mpow(i+1, MOD-2) % MOD;
            }


            long[] nmk = ILongs();

            long n = nmk[0];
            long m = nmk[1];
            long k = nmk[2];

            long combi = 0; //todo

            long ans = 0;

            long pow = 1;

            if(m==1){
                WriteLine(k==n-1 ? 1 : 0);
                return;
            }
            if(k!=n-1){
                for(int i=0;i<n-1-k-1;i++){
                    pow *= m-1;
                    pow %= MOD;
                }
            }

            for(long i=k;i>=0;i--){
                combi = Comb(n-1, i); //100じゃない
                pow *= m-1;
                pow %= MOD;
                ans += combi * m * pow;
                ans %= MOD;
            }

            WriteLine(ans);
        }

        static long Comb(long a,long b){
            if(a==0&&b==0)return 1;
            if(a<b||a<0)return 0;
            long tmp = ifac[a-b]*ifac[b]%MOD;
            return tmp * fac[a]%MOD;
        }

        static long Mpow(long x,long n){
            long ans = 1;
            while(n!=0){
                if(n%2==1)ans = ans *x%MOD;
                x = x*x % MOD; 
                n = n /2;
            }
            return ans;
        }

        static readonly long MOD = 998244353;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}