Problem p02169 - Generation 3

Orig Description

Problem H: Count Words
Problem
  There are $M$ types of characters. Create a string of length $N$ using these characters. How many strings have at least $K$ different types of characters used in them? Find the answer modulo $998244353$.
  Here two strings of length $N$ are considered different if there exists an $i$ $(1 \leq i \leq N)$ such that $S_i \neq T_i$ where $S = S_1S_2 \ldots S_N$ and $T = T_1T_2 \ldots T_N$.
Input
The input is given in the following format:
$M$ $N$ $K$
  $M, N,$ and $K$ are given on a single line separated by a single space.
Constraints
The input satisfies the following constraints:
$1 \leq M \leq 10^{18} $
$1 \leq N \leq 10^{18} $
$1 \leq K \leq 1000 $
All input values are integers.
Output
  Print the number of strings of length $N$ using $M$ characters such that at least $K$ different types of characters are used. The answer should be printed modulo $998244353$.
Sample Input 1
2 10 1
Sample Output 1
1024
Sample Input 2
1 1 2
Sample Output 2
0
Sample Input 3
5 10 3
Sample Output 3
9755400
Sample Input 4
7 8 3
Sample Output 4
5759460
Sample Input 5
1000000000000000000 1000000000000000000 1000
Sample Output 5
133611974

Extracted Specification

Canonicalized Input Description:

An integer M (1 ≤ M ≤ 10^18), representing some quantity.
An integer N (1 ≤ N ≤ 10^18), representing some quantity.
An integer K (1 ≤ K ≤ 1000), representing some quantity.

### Example Input:

```
2 10 1
```

### Function Signature:
Write a function f(M, N, K) that takes in the input.
def f(M: int, N: int, K: int):
    '''
    M: an integer
    N: an integer
    K: an integer
    '''

Test Case Generator

Certainly! Below is a Python function for generating test cases for the given problem, "Count Words."

```python
import random

def tcgen():
    # Constraints
    M_min, M_max = 1, 10**18
    N_min, N_max = 1, 10**18
    K_min, K_max = 1, 1000

    # Generate M, N, and K within the specified ranges
    M = random.randint(M_min, M_max)
    N = random.randint(N_min, N_max)
    K = random.randint(K_min, K_max)

    # Ensure K is not greater than the minimum of M or N
    K = min(K, M, N)

    return M, N, K

# Example usage:
for _ in range(10):
    print(tcgen())
```

### Explanation:

1. **Constraints:**
    - \( M \): Number of types of characters (1 ≤ \( M \) ≤ \( 10^{18} \)).
    - \( N \): Length of the string (1 ≤ \( N \) ≤ \( 10^{18} \)).
    - \( K \): Minimum number of different types of characters to be used in the string (1 ≤ \( K \) ≤ 1000).

2. **Random Generation:**
    - Randomly generate \( M \) and \( N \) within their respective ranges.
    - Randomly generate \( K \) within its range but ensure it's not greater than the minimum of \( M \) or \( N \) to maintain logical consistency.

3. **Example Usage:**
    - The function can be called multiple times to generate different test cases.

This function will generate random test cases while respecting the constraints provided in the problem statement.

Extract Arguments

def extract_arguments(fh):
    M, N, K = map(int, fh.readline().strip().split())
    return M, N, K