P11253 [GDKOI2023 Junior] Elementary School Math Problem.
Description
Moon is an elementary school student. While doing homework, he encountered the following problem: given positive integers $n, k$, find the value of the expression:
$$\sum_{i=1}^n \frac{i!}{i^k}$$
Here, $i!$ denotes the factorial of $i$, that is, $i! = 1 \times 2 \times 3 \times 4 \ldots \times i$. This expression is too hard, so Moon hopes to get your help. However, since Moon has only learned integer operations and has not learned real-number operations, he wants you to help him compute the value of this expression modulo $998244353$. That is, if the final result can be simplified into an irreducible fraction $\frac{p}{q}$, you only need to output $p \times q^{-1} \bmod 998244353$, where $q^{-1}$ is the modular inverse of $q$ modulo $998244353$.
Input Format
The first line contains two integers $n, k$.
Output Format
One line with one integer, representing the answer modulo $998244353$.
Explanation/Hint
### Sample Explanation
In sample $1$, since $\frac{i!}{i} = (i - 1)!$, the original expression is equivalent to $\sum_{i=1}^5 (i - 1)! = 34$.
### Constraints
For all testdata, $1 \le n, k \le 2 \times 10^7$.
For $30\%$ of the testdata, $k = 1$.
For another $30\%$ of the testdata, $1 \le k \le 3$.
Translated by ChatGPT 5