CF1030G.Linear Congruential Generator
普及/提高-
通过率:0%
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
输入格式
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 ).
输出格式
Print one integer — the maximum number of different tuples modulo 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] .