CF1477F.Nezzar and Chocolate Bars

NOI/NOI+/CTSC

通过率:0%

时间限制:5.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Nezzar buys his favorite snack — nn chocolate bars with lengths l1,l2,…,lnl_1,l_2,\ldots,l_n. However, chocolate bars might be too long to store them properly!

In order to solve this problem, Nezzar designs an interesting process to divide them into small pieces. Firstly, Nezzar puts all his chocolate bars into a black box. Then, he will perform the following operation repeatedly until the maximum length over all chocolate bars does not exceed kk.

  • Nezzar picks a chocolate bar from the box with probability proportional to its length xx.
  • After step 11, Nezzar uniformly picks a real number r∈(0,x)r \in (0,x) and divides the chosen chocolate bar into two chocolate bars with lengths rr and x−rx-r.
  • Lastly, he puts those two new chocolate bars into the black box.

Nezzar now wonders, what is the expected number of operations he will perform to divide his chocolate bars into small pieces.

It can be shown that the answer can be represented as PQ\frac{P}{Q}, where PP and QQ are coprime integers and Q≢0Q \not \equiv 0 ( mod 998 244 353\bmod 998\,244\,353). Print the value of P⋅Q−1mod  998 244 353P\cdot Q^{-1} \mod 998\,244\,353.

Nezzar 购买了他最喜爱的零食——nn 块长度分别为 l1,l2,…,lnl_1, l_2, \ldots, l_n 的巧克力棒。然而,这些巧克力棒可能过长,难以妥善存放!

为了解决这个问题,Nezzar 设计了一种有趣的分割过程,将它们切分为更小的段。首先,Nezzar 将所有巧克力棒放入一个黑箱中。然后,他将重复执行以下操作,直到所有巧克力棒中的最大长度不超过 kk。

  • Nezzar 以与巧克力棒当前长度 xx 成正比的概率,从黑箱中随机选取一根巧克力棒;
  • 在第 1 步之后,Nezzar 在区间 (0,x)(0, x) 内均匀随机选取一个实数 rr,并将所选巧克力棒切成两段,长度分别为 rr 和 x−rx - r;
  • 最后,他将这两段新巧克力棒放回黑箱中。

Nezzar 现在想知道:他需要执行的操作次数的期望值是多少?

可以证明,该答案可表示为 PQ\frac{P}{Q},其中 PP 与 QQ 互质,且 Q≢0(mod998 244 353)Q \not\equiv 0 \pmod{998\,244\,353}。请输出 P⋅Q−1 mod 998 244 353P \cdot Q^{-1} \bmod 998\,244\,353 的值。

输入格式

The first line contains two integers nn and kk (1≤n≤50,1≤k≤20001 \le n \le 50, 1 \le k \le 2000).

The second line contains nn integers l1,l2,…,lnl_1, l_2, \ldots, l_n (1≤li1 \le l_i, ∑i=1nli≤2000\sum_{i=1}^{n} l_i \le 2000).

第一行包含两个整数 nn 和 kk(1≤n≤501 \le n \le 50,1≤k≤20001 \le k \le 2000)。

第二行包含 nn 个整数 l1,l2,…,lnl_1, l_2, \ldots, l_n(1≤li1 \le l_i,且 ∑i=1nli≤2000\sum_{i=1}^{n} l_i \le 2000)。

输出格式

Print a single integer — the expected number of operations Nezzar will perform to divide his chocolate bars into small pieces modulo 998 244 353998\,244\,353.

输出一个整数——Nezzar 将巧克力棒分割成小块所需的期望操作次数,对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    1 1
    2

    输出#1

    4
  • 输入#2

    1 1
    1

    输出#2

    0
  • 输入#3

    1 5
    1234

    输出#3

    15630811
  • 输入#4

    2 1
    2 3

    输出#4

    476014684
  • 输入#5

    10 33
    10 20 30 40 50 60 70 80 90 100

    输出#5

    675105648

输入解题思路,AI测评打分。不知道怎么写?

首页