問題一覧 > 通常問題

No.125 Petals of Evil

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 76
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 167 / 自分の提出
問題文最終更新日: 2026-06-25 07:46:01
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 75 (順位表) の他の問題:

Problem Statement

Petals have been made in order to artificially create a large, beautiful flower.
All petals have the same shape, but differ in color.
There are $K$ colors, numbered from $1$ to $K$, and there are $C_i$ petals of color $i$.
A flower is made by arranging all of these petals in a circle.
Write a program that finds the number of different flowers that can be made.
Here, arrangements that coincide by rotation are considered the same flower.
Even if two arrangements coincide when flipped upside down, they are considered different flowers unless they coincide by rotation.
Since the answer can be large, output the remainder when divided by $10^9+7$.

Input

$K$
$C_1$ $C_2$ $\cdots$ $C_K$

$1 \leq K \leq 10^5$
$C_1 + C_2 + \cdots + C_K \leq 10^6$
$C_k \geq 1$

Output

Output the number of flower patterns that can be made, ${\rm mod}\ 10^9+7$, on $1$ line.
Print a newline at the end.

Sample

Sample 1
Input
2
2 2
Output
2

There are $2$ ways: petals of the same color are adjacent, or the colors alternate.

Sample 2
Input
2
9 1
Output
1

There is $1$ petal of a different color, but all arrangements coincide by rotation.

Sample 3
Input
3
8 1 1
Output
9

When the petal of color $2$ is fixed, $9$ different flowers can be made depending on where the petal of color $3$ is placed.
Note that arrangements that coincide by mirror reflection but do not coincide by rotation are considered different flowers.

Sample 4
Input
3
3 3 3
Output
188

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