CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!)
G
Tenzing and Random Operations
Codeforces
2800
原题
← FH →
翻译中…

Yet another random problem.

翻译中…

Tenzing has an array $a$ of length $n$ and an integer $v$.

翻译中…

Tenzing will perform the following operation $m$ times:

翻译中…
  1. Choose an integer $i$ such that $1 \leq i \leq n$ uniformly at random.
  2. For all $j$ such that $i \leq j \leq n$, set $a_j := a_j + v$.
翻译中…

Tenzing wants to know the expected value of $\prod_{i=1}^n a_i$ after performing the $m$ operations, modulo $10^9+7$.

翻译中…

Formally, let $M = 10^9+7$. It can be shown that the answer can be expressed as an irreducible fraction $\frac{p}{q}$, where $p$ and $q$ are integers and $q \not \equiv 0 \pmod{M}$. Output the integer equal to $p \cdot q^{-1} \bmod M$. In other words, output the integer $x$ that $0 \le x \lt M$ and $x \cdot q \equiv p \pmod{M}$.

翻译中…

Input

翻译中…

The first line of input contains three integers $n$, $m$ and $v$ ($1\leq n\leq 5000$, $1\leq m,v\leq 10^9$).

翻译中…

The second line of input contains $n$ integers $a_1,a_2,\ldots,a_n$ ($1\leq a_i\leq 10^9$).

翻译中…

Output

翻译中…

Output the expected value of $\prod_{i=1}^n a_i$ modulo $10^9+7$.

翻译中…

Note

翻译中…

There are three types of $a$ after performing all the $m$ operations :

翻译中…
  1. $a_1=2,a_2=12$ with $\frac{1}{4}$ probability.
翻译中…
  1. $a_1=a_2=12$ with $\frac{1}{4}$ probability.
翻译中…
  1. $a_1=7,a_2=12$ with $\frac{1}{2}$ probability.
翻译中…

So the expected value of $a_1\cdot a_2$ is $\frac{1}{4}\cdot (24+144) + \frac{1}{2}\cdot 84=84$.

翻译中…

样例

Input #1
2 2 5
2 2
Output #1
84
InputCopy OutputCopy
Input #2
5 7 9
9 9 8 2 4
Output #2
975544726
InputCopy OutputCopy
题目信息
题号
1842G
时间限制
2 s
内存限制
1024 MB
标签
组合数学
动态规划
数学
概率论

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