No.995 タピオカオイシクナーレ
タグ : / 解いたユーザー数 193
作問者 :
ganmodokix
/ テスター :
monkukui2
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
You are a maid working at the maid café "Zerokan☀Taiyo". Today you are to serve a tapioca milk tea to a regular master, but just before serving it you realized that you may have accidentally put unappetizing tapioca pearls into the milk tea.
There are $N$ tapioca pearls, distinguished by the numbers $1,2,\cdots,N$. The tastiness of tapioca pearl $i$ is a positive integer $b_i$. Currently, tapioca pearls $1, 2, \cdots, M$ are in the milk tea, and all the others are in the kitchen. The tastiness of the tapioca milk tea equals the sum of the tastiness of the tapioca pearls in it.
You can use your Moe-Moe Power exactly $K$ times to teleport tapioca pearls. Each time you use the power, independently for each pearl, with probability $\frac{p}{q}$, a pearl in the milk tea moves to the kitchen, and a pearl in the kitchen moves into the milk tea. The numbers of pearls in the milk tea and in the kitchen are not necessarily preserved, the teleportation occurs independently for each pearl, and it is possible that not even $1$ pearl moves despite using the power.
After using the Moe-Moe Power exactly $K$ times, what is the expected value of the tastiness of the tapioca milk tea served to the master?
The expected value is a rational number, and under the constraints it is guaranteed that it can be expressed as $\frac{x}{y}$ with a positive integer $x$ and a positive integer $y$ that is not a multiple of $10^9+7$. Output the unique non-negative integer $R$ satisfying $0\le R \lt 10^9+7$ and $x \equiv yR \bmod{10^9+7}$.
Input
$N\ M\ K\ p\ q$ $b_1$ $b_2$ $\vdots$ $b_N$
The input satisfies the following constraints. Since the input is large, it is recommended to use a fast language such as PyPy or C++ rather than Python or the like.
- $1\le N\le 10^5$
- $0\le M\le N$
- $1\le K\le 10^{12}$
- $1\le p \lt q \le 10^9$
- $1\le b_i \le 10^9$
- All input values are integers.
Output
Output the expected value in the format described in the problem statement, followed by a newline.
Sample
Sample 1
Input
1 0 1 1 2 1
Output
500000004
The probability that the tapioca pearl you forgot to put in teleports with $1$ use of the power is $\frac{1}{2}$.
Sample 2
Input
4 3 4 1 4 4 4 4 4
Output
250000010
The expected value to be found is $\frac{33}{4}$, so output $R=250000010$, the unique integer that is at least $0$ and less than $10^9+7$ satisfying $33\equiv 4R\bmod{10^9+7}$.
Sample 3
Input
5 2 314159265358 1729 87539319 12345678 99999996 99999997 99999998 99999999
Output
57524728
Be careful of overflow.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。