A13969 | Nezzar and Chocolate Bars
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Nezzar buys his favorite snack — $n$ chocolate bars with lengths $l_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 $k$ .
- Nezzar picks a chocolate bar from the box with probability proportional to its length $x$ .
- After step $1$ , Nezzar uniformly picks a real number $r \in (0,x)$ and divides the chosen chocolate bar into two chocolate bars with lengths $r$ and $x-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 $\frac{P}{Q}$ , where $P$ and $Q$ are coprime integers and $Q \not \equiv 0$ ( $\bmod 998\,244\,353$ ). Print the value of $P\cdot Q^{-1} \mod 998\,244\,353$ .
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 $k$ .
- Nezzar picks a chocolate bar from the box with probability proportional to its length $x$ .
- After step $1$ , Nezzar uniformly picks a real number $r \in (0,x)$ and divides the chosen chocolate bar into two chocolate bars with lengths $r$ and $x-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 $\frac{P}{Q}$ , where $P$ and $Q$ are coprime integers and $Q \not \equiv 0$ ( $\bmod 998\,244\,353$ ). Print the value of $P\cdot Q^{-1} \mod 998\,244\,353$ .
输入格式
The first line contains two integers $n$ and $k$ ( $1 \le n \le 50, 1 \le k \le 2000$ ).
The second line contains $n$ integers $l_1, l_2, \ldots, l_n$ ( $1 \le l_i$ , $\sum_{i=1}^{n} l_i \le 2000$ ).
The second line contains $n$ integers $l_1, l_2, \ldots, l_n$ ( $1 \le l_i$ , $\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\,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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted