AtCoder Beginner Contest 226
H
Random Kth Max
AtCoder
⌀ 2813
原题
← G→
翻译中…

Problem Statement

翻译中…

We have $N$ continuous random variables $X_1,X_2,\dots,X_N$. $X_i$ has a continuous uniform distribution over the interval $\lbrack L_i, R_i \rbrack$. Let $E$ be the expected value of the $K$-th greatest value among the $N$ random variables. Print $E \bmod {998244353}$ as specified in Notes.

翻译中…

Note

翻译中…

In this problem, we can prove that $E$ is always a rational number. Additionally, the Constraints of this problem guarantee that, when $E$ is represented as an irreducible fraction $\frac{y}{x}$, $x$ is indivisible by $998244353$. Here, there uniquely exists an integer $z$ between $0$ and $998244352$ such that $xz \equiv y \pmod{998244353}$. Print this $z$ as the value $E \bmod {998244353}$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 50$
  • $1 \leq K \leq N$
  • $0 \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:

翻译中…

N K
L_1 R_1
L_2 R_2
\vdots
L_N R_N

翻译中…

Output

翻译中…

Print $E \bmod {998244353}$.

翻译中…

样例

Input #1
1 1
0 2
Output #1
1
The answer is the expected value of the random variable with a continuous uniform distribution over the interval $\lbrack 0, 2 \rbrack$. Thus, we should print $1$.
Input #2
2 2
0 2
1 3
Output #2
707089751
The answer represented as a rational number is $\frac{23}{24}$. We have $707089751 \times 24 \equiv 23 \pmod{998244353}$, so we should print $707089751$.
Input #3
10 5
35 48
44 64
47 59
39 97
36 37
4 91
38 82
20 84
38 50
39 69
Output #3
810056397
题目信息
题号
abc226_h
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。