#abc226h. H - Random Kth Max

H - Random Kth Max

Score : 600600 points

问题描述

我们有 NN 个连续随机变量 X1,X2,,XNX_1, X_2, \dots, X_N。其中,XiX_i 在区间 [Li,Ri]\lbrack L_i, R_i \rbrack 上服从均匀分布。

EE 表示这 NN 个随机变量中第 KK 大值的期望值。按照 Notes 中的规定,输出 Emod998244353E \bmod {998244353} 的结果。

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

Problem Statement

We have NN continuous random variables X1,X2,,XNX_1,X_2,\dots,X_N. XiX_i has a continuous uniform distribution over the interval [Li,Ri]\lbrack L_i, R_i \rbrack.
Let EE be the expected value of the KK-th greatest value among the NN random variables. Print Emod998244353E \bmod {998244353} as specified in Notes.

Notes

In this problem, we can prove that EE is always a rational number. Additionally, the Constraints of this problem guarantee that, when EE is represented as an irreducible fraction yx\frac{y}{x}, xx is indivisible by 998244353998244353.
Here, there uniquely exists an integer zz between 00 and 998244352998244352 such that xzy(mod998244353)xz \equiv y \pmod{998244353}. Print this zz as the value Emod998244353E \bmod {998244353}.

Constraints

  • 1N501 \leq N \leq 50
  • 1KN1 \leq K \leq N
  • 0Li<Ri1000 \leq L_i \lt R_i \leq 100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

L1L_1 R1R_1

L2L_2 R2R_2

\vdots

LNL_N RNR_N

Output

Print Emod998244353E \bmod {998244353}.

Sample Input 1

1 1
0 2

Sample Output 1

1

The answer is the expected value of the random variable with a continuous uniform distribution over the interval [0,2]\lbrack 0, 2 \rbrack. Thus, we should print 11.

Sample Input 2

2 2
0 2
1 3

Sample Output 2

707089751

The answer represented as a rational number is 2324\frac{23}{24}. We have 707089751×2423(mod998244353)707089751 \times 24 \equiv 23 \pmod{998244353}, so we should print 707089751707089751.

Sample Input 3

10 5
35 48
44 64
47 59
39 97
36 37
4 91
38 82
20 84
38 50
39 69

Sample Output 3

810056397

update @ 2024/3/10 09:56:30