题目描述
Problem Description
We are given $ N $ integers $A_1, A_2, \ldots, A_N$. We need to select $ K $ distinct integers from these. Each possible set of $ K $ integers is equally likely to be chosen.
Let $ X $ be the maximum value and $ Y $ be the minimum value of the selected integers. Compute the expected value of $ X - Y $ modulo $ 998244353 $.
Input Format
The input is provided from the standard input in the following format:
$ N $ $ K $ $ A_1 $ $ A_2 $ $\ldots$ $ A_N $
Output Format
Output the answer.
Sample Input and Output
Sample Input #1
3 2
3 7 5
Sample Output #1
665496238
Sample Input #2
3 1
3 7 5
Sample Output #2
0
Sample Input #3
10 5
384 887 778 916 794 336 387 493 650 422
Sample Output #3
621922587
Notes/Hints
Note
Under the constraints of this problem, it can be proven that the expected value can be expressed as $ p/q $ using two coprime integers $ p $ and $ q $. There exists a unique integer $ r $ such that $\equiv p \pmod{998244353}$ and $0 \leq r < 998244353$. This $ r $ is the value to be found.
Constraints
- $1 \leq K \leq N \leq 2 \times 10^5$
- $1 \leq A_i \leq 10^9$
- $ A_i $ are distinct
- All inputs are integers
Sample Explanation 1
The possible sets of $ K $ values are as follows, each chosen with equal probability:
- $\{3, 7\}$: Here, $ X - Y = 7 - 3 = 4 $
- $\{3, 5\}$: Here, $ X - Y = 5 - 3 = 2 $
- $\{7, 5\}$: Here, $ X - Y = 7 - 5 = 2 $
The expected value is $\dfrac{4 + 2 + 2}{3} = \dfrac{8}{3}$, which modulo $ 998244353 $ is $ 665496238 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分