当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6327:Problem I. Random Sequence

题目描述
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.
输入解释
The first line of the input contains an integer $T(1\leq T\leq10)$, denoting the number of test cases.
In each test case, there are $2$ integers $n,m(4\leq n\leq 100,1\leq m\leq 100)$ in the first line, denoting the length of the sequence and the bound of each number.
In the second line, there are $n$ integers $a_1,a_2,...,a_n(0\leq a_i\leq m)$, denoting the sequence.
In the third line, there are $m$ integers $v_1,v_2,...v_m(1\leq v_i\leq 10^9)$, denoting the array $v$.
输出解释
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
输出样例
8000
3
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6327

最后修改于 2020-10-25T23:30:19+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)