Problem Statement
You are given a permutation $P$ of $(1,2,\dots,N)$ and an integer $K$.
Find the expected value, modulo $998244353$, of the inversion number of $P$ after performing the following operation:
- First, choose an integer
$i$uniformly at random between$1$and$N - K + 1$, inclusive. - Then, shuffle
$P_i, P_{i+1}, \dots, P_{i+K-1}$uniformly at random.
What is the inversion number? The inversion number of a sequence $(A_1, A_2, \dots, A_N)$ is the number of integer pairs $(i, j)$ satisfying $1 \le i < j \le N$ and $A_i > A_j$.
What does "expected value modulo $998244353$" mean? It can be proved that the sought expected value is always rational. Under the constraints of this problem, when this value is represented as an irreducible fraction $\frac{P}{Q}$, it can also be proved that $Q \not\equiv 0 \pmod{998244353}$. Thus, there is a unique integer $R$ satisfying $R \times Q \equiv P \pmod{998244353}, \ 0 \le R < 998244353$. Report this integer $R$.
Constraints
- All input values are integers.
$1 \le K \le N \le 2 \times 10^5$$P$is a permutation of$(1,2,\dots,N)$.
Input
The input is given from Standard Input in the following format:
N K
P_1 P_2 \dots P_N
Output
Print the answer in one line.
样例
4 2
1 4 2 3
166374061
1 1
1
0
10 6
7 4 10 5 6 1 8 2 3 9
499122200
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。