CF1030G.Linear Congruential Generator
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a tuple generator f(k)=(f1(k),f2(k),…,fn(k)), where fi(k)=(ai⋅fi(k−1)+bi)modpi and f(0)=(x1,x2,…,xn). Here xmody denotes the remainder of x when divided by y. All pi are primes.
One can see that with fixed sequences xi, yi, ai the tuples f(k) starting from some index will repeat tuples with smaller indices. Calculate the maximum number of different tuples (from all f(k) for k≥0) that can be produced by this generator, if xi, ai, bi are integers in the range [0,pi−1] and can be chosen arbitrary. The answer can be large, so print the remainder it gives when divided by 109+7
给定一个元组生成器 f(k)=(f1(k),f2(k),…,fn(k)),其中
fi(k)=(ai⋅fi(k−1)+bi)modpi,
且初始元组为 f(0)=(x1,x2,…,xn)。此处 xmody 表示 x 除以 y 的余数。所有 pi 均为素数。
可以发现,对于固定的序列 xi、ai、bi,元组序列 f(k) 从某个下标开始将重复之前出现过的元组(即进入循环)。现要求:在 xi、ai、bi 均可任意选取、且均取自整数区间 [0,pi−1] 的前提下,该生成器所能产生的不同元组的最大个数(即对所有 k≥0 的 f(k) 中互异元组的总数最大值)。答案可能很大,请输出其对 109+7 取模的结果。
输入格式
The first line contains one integer n (1≤n≤2⋅105) — the number of elements in the tuple.
The second line contains n space separated prime numbers — the modules p1,p2,…,pn (2≤pi≤2⋅106).
第一行包含一个整数 n(1≤n≤2⋅105)—— 元组中元素的个数。
第二行包含 n 个以空格分隔的素数 —— 模数 p1,p2,…,pn(2≤pi≤2⋅106)。
输出格式
Print one integer — the maximum number of different tuples modulo 109+7.
输出一个整数——模 109+7 意义下不同元组的最大数量。
输入输出样例
输入#1
4 2 3 5 7
输出#1
210
输入#2
3 5 3 3
输出#2
30
说明/提示
In the first example we can choose next parameters: a=[1,1,1,1], b=[1,1,1,1], x=[0,0,0,0], then fi(k)=kmodpi.
In the second example we can choose next parameters: a=[1,1,2], b=[1,1,0], x=[0,0,1].
在第一个例子中,我们可以选择以下参数:a=[1,1,1,1],b=[1,1,1,1],x=[0,0,0,0],此时有 fi(k)=kmodpi。
在第二个例子中,我们可以选择以下参数:a=[1,1,2],b=[1,1,0],x=[0,0,1]。
输入解题思路,AI测评打分。不知道怎么写?