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

建议使用的浏览器:

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

5684:zxa and lcm

题目描述
zxa had a great interest in least common multiple(i.e. LCM) recently, therefore he defined $lcm(i,j)(i,j\in N^*)$ as the smallest positive integer which is divisible by both positive integer $i$ and positive integer $j$. Moreover, for any $n(n>2)$ positive integers $\{a_1,a_2,\cdots,a_n\}$, he defined that $lcm(a_1,a_2,\cdots,a_n)=lcm(lcm(a_1,a_2,\cdots,a_{n-1}),a_n)$.

zxa gave **a prime integer $p$**, choses a positive integer $x(1 < x < p)$ as random seed and used the formula $f_0=0,f_i=f_{i-1}\cdot x+1$ to generate a sequence $\{f_1,f_2,\cdots,f_m\}$ of length $m$.

zxa is interested to know, assuming that he gave a sequence $\{a_1,a_2,\cdots,a_n\}$ of length $n$, where each $a_i$ is positive integer and $\max_{1\leq i\leq n}{a_i}=m$, then what is the value of $lcm(f_{a_1},f_{a_2},\cdots,f_{a_n})$, can you help him?

The answer may be very large, so that you only need to give the value of the answer modulo $p$.
输入解释
The first line contains an positive integer $T$, represents there are $T$ test cases.

For each test case:

The first line contains four positive integers $n,m,p$ and $x$.

The second line contains $n$ positive integers, represent $a_1,a_2,\cdots,a_n$.

There is a blank between each integer with no other extra space in one line.

$1\leq T\leq 1000,1 < n\leq 10^5,1\leq m\leq 10^5,1 < x < p < 2^{31},1\leq a_i\leq m,1\leq\sum{n},\sum{m}\leq10^6$
输出解释
For each test case, output in one line a non-negative integer, repersents the value of $lcm(f_{a_1},f_{a_2},\cdots,f_{a_n})$ modulo $p$.
输入样例
1
5 5 2333 2
1 2 3 4 5
输出样例
922 

提示
$lcm(1,3,7,15,31)=3255$.
来自杭电HDUOJ的附加信息
Recommend wange2014

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

题目来源 BestCoder Round #83

源链接: HDU-5684

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

共提交 0

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