No.125 Petals of Evil
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
LayCurse