問題一覧 > 通常問題

No.2235 Line Up Colored Balls

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 86
作問者 : srjywrdnprkt / テスター : t98slider
お気に入りにしたユーザー ProblemId : 9105 / 自分の提出
問題文最終更新日: 2023-06-02 00:40:07
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. Back to the original
yukicoder contest 379 (順位表) の他の問題:

Problem Statement

There are $N$ colors $1,~2,~\cdots,~N$. There is also a bag that contains, for each $i$, $x_i$ balls painted in color $i$.

You take balls out of the bag one at a time until the bag is empty, and line them up in a row. Here, each ball is equally likely to be taken out.

Next, you split the row at every place where balls of different colors are adjacent. The number of contiguous subarrays obtained by this operation is called the discontinuity of the row.
Under the constraints of this problem, it can be proved that the expected value of the discontinuity of the resulting row is a rational number. Find this value $\mod (10^9+7)$.

  • Definition of a rational number $\mod (10^9+7)$

Under the constraints of this problem, it can be shown that when the expected value to be found is expressed as an irreducible fraction $\frac{P}{Q}$ using coprime positive integers $P,~Q$, $Q$ is not divisible by $10^9+7$, and that an integer $R$ between $0$ and less than $10^9+7$ satisfying $P \equiv Q\times R \mod (10^9+7)$ is uniquely determined. Find this $R$.

Input

$N$
$x_1~\cdots~x_N$

All input values are integers and satisfy the following constraints.

  • $1\leq N \leq 10^5$
  • $1 \leq x_i$
  • $\displaystyle \sum_{i=1}^N x_i \leq 10^{9}$

Output

Output the expected value of the discontinuity of the resulting row $\mod (10^9+7)$. Print a newline at the end.

Sample

Sample 1
Input
2
2 1
Output
333333338

Let a denote a ball of color $1$ and b denote a ball of color $2$. When these are arranged randomly, the 3 rows (aab, aba, baa) are obtained with equal probability.
aab can be split as aa b, so its discontinuity is $2$; aba can be split as a b a, so its discontinuity is $3$; baa can be split as b aa, so its discontinuity is $2$.
Therefore, the expected value of the discontinuity is $\frac{7}{3}$. Since $3 \times 333333338\mod (10^9+7)\equiv 7$, the answer is $333333338$.

Sample 2
Input
1
100
Output
1

All the balls are the same color, so the discontinuity can only be 1.

Sample 3
Input
4
1 1 1 1
Output
4

The discontinuity is 4 for every arrangement.

Sample 4
Input
10
3 1 4 1 5 9 2 6 5 3
Output
384615422

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。