Problem I. Problem I. Random Sequence
时间限制 1000 ms
内存限制 512 MB
There is a positive integer sequence $a_1,a_2,...,a_n$ with some unknown positions, denoted by 0. Little Q will replace each 0 by a random integer within the range $[1,m]$ equiprobably. After that, he will calculate the value of this sequence using the following formula :
\begin{eqnarray*}
\prod_{i=1}^{n-3} v[\gcd(a_i,a_{i+1},a_{i+2},a_{i+3})]
\end{eqnarray*}
Little Q is wondering what is the expected value of this sequence. Please write a program to calculate the expected value.
输入数据
输出数据
For each test case, print a single line containing an integer, denoting the expected value. If the answer is $\frac{A}{B}$, please print $C(0\leq C<10^9+7)$ where $A\equiv C\times B\pmod{10^9+7}$.
样例输入
复制
2
6 8
4 8 8 4 6 5
10 20 30 40 50 60 70 80
4 3
0 0 0 0
3 2 4
样例输出
$ Mathjax font initiator $