O - 文字列
Editorial
/
以下の条件を満たす文字列の個数を mod 1,000,000,007 で求めよ。
入力は以下の形式で標準入力から与えられる。
答えを一行に出力せよ。
acad, adac, acda, adca, cada, daca が条件を満たす。
Time Limit: 2 sec / Memory Limit: 256 MB
Problem Statement
- a を freq_1 個、b を freq_2 個、... z を freq_{26} 個含む (他の文字は含まない)。
- 同じ文字が隣り合うことはない。
Constraints
- 0 ≤ freq_i ≤ 10
- At least one of freq_i will be nonzero.
Input Format
freq_1 ... freq_{26}
Output Format
Sample Input 1
1 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output 1
6
Sample Input 2
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output 2
3628800