#abc295e. E - Kth Number

E - Kth Number

Score : 500500 points

问题描述

我们有一个长度为 NN 的整数序列,其中的整数介于 00MM(包含两端)之间:A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N)

Snuke 将按照以下顺序执行操作 1 和 2。

  1. 对于每个满足 Ai=0A_i=0ii,独立地从 11MM(包含两端)中均匀随机选择一个整数,并用该整数替换 AiA_i
  2. 将序列 AA 按升序排序。

计算并输出经过这两个操作后 AKA_K 的期望值,结果对 998244353998244353 取模。

如何打印模 998244353998244353 的数?可以证明所求期望值总是有理数。此外,在本题的约束条件下,若将该期望值表示为两个互质整数 PPQQ 的形式 PQ\frac{P}{Q},可以证明存在唯一的整数 RR,满足 R×QP(mod998244353)R \times Q \equiv P\pmod{998244353}0R<9982443530 \leq R < 998244353。请打印这个 RR

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have a sequence of length NN consisting of integers between 00 and MM, inclusive: A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N).

Snuke will perform the following operations 1 and 2 in order.

  1. For each ii such that Ai=0A_i=0, independently choose a uniform random integer between 11 and MM, inclusive, and replace AiA_i with that integer.
  2. Sort AA in ascending order.

Print the expected value of AKA_K after the two operations, modulo 998244353998244353.

How to print a number modulo 998244353998244353? It can be proved that the sought expected value is always rational. Additionally, under the Constraints of this problem, when that value is represented as PQ\frac{P}{Q} using two coprime integers PP and QQ, it can be proved that there is a unique integer RR such that R×QP(mod998244353)R \times Q \equiv P\pmod{998244353} and 0R<9982443530 \leq R \lt 998244353. Print this RR.

Constraints

  • 1KN20001\leq K \leq N \leq 2000
  • 1M20001\leq M \leq 2000
  • 0AiM0\leq A_i \leq M
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM KK

A1A_1 A2A_2 \dots ANA_N

Output

Print the expected value of AKA_K after the two operations, modulo 998244353998244353.

Sample Input 1

3 5 2
2 0 4

Sample Output 1

3

In the operation 1, Snuke will replace A2A_2 with an integer between 11 and 55. Let xx be this integer.

  • If x=1x=1 or 22, we will have A2=2A_2=2 after the two operations.
  • If x=3x=3, we will have A2=3A_2=3 after the two operations.
  • If x=4x=4 or 55, we will have A2=4A_2=4 after the two operations.

Thus, the expected value of A2A_2 is 2+2+3+4+45=3\frac{2+2+3+4+4}{5}=3.

Sample Input 2

2 3 1
0 0

Sample Output 2

221832080

The expected value is 149\frac{14}{9}.

Sample Input 3

10 20 7
6 5 0 2 0 0 0 15 0 0

Sample Output 3

617586310

update @ 2024/3/10 12:16:29