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))f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)}), where fi(k)=(ai⋅fi(k−1)+bi) mod pif_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i and f(0)=(x1,x2,…,xn)f^{(0)} = (x_1, x_2, \dots, x_n). Here x mod yx \bmod y denotes the remainder of xx when divided by yy. All pip_i are primes.

One can see that with fixed sequences xix_i, yiy_i, aia_i the tuples f(k)f^{(k)} starting from some index will repeat tuples with smaller indices. Calculate the maximum number of different tuples (from all f(k)f^{(k)} for k≥0k \ge 0) that can be produced by this generator, if xix_i, aia_i, bib_i are integers in the range [0,pi−1][0, p_i - 1] and can be chosen arbitrary. The answer can be large, so print the remainder it gives when divided by 109+710^9 + 7

给定一个元组生成器 f(k)=(f1(k),f2(k),…,fn(k))f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)}),其中

fi(k)=(ai⋅fi(k−1)+bi) mod pi,f_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i,

且初始元组为 f(0)=(x1,x2,…,xn)f^{(0)} = (x_1, x_2, \dots, x_n)。此处 x mod yx \bmod y 表示 xx 除以 yy 的余数。所有 pip_i 均为素数。

可以发现,对于固定的序列 xix_i、aia_i、bib_i,元组序列 f(k)f^{(k)} 从某个下标开始将重复之前出现过的元组(即进入循环)。现要求:在 xix_i、aia_i、bib_i 均可任意选取、且均取自整数区间 [0,pi−1][0, p_i - 1] 的前提下,该生成器所能产生的不同元组的最大个数(即对所有 k≥0k \ge 0 的 f(k)f^{(k)} 中互异元组的总数最大值)。答案可能很大,请输出其对 109+710^9 + 7 取模的结果。

输入格式

The first line contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of elements in the tuple.

The second line contains nn space separated prime numbers — the modules p1,p2,…,pnp_1, p_2, \ldots, p_n (2≤pi≤2⋅1062 \le p_i \le 2 \cdot 10^6).

第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 元组中元素的个数。

第二行包含 nn 个以空格分隔的素数 —— 模数 p1,p2,…,pnp_1, p_2, \ldots, p_n(2≤pi≤2⋅1062 \le p_i \le 2 \cdot 10^6)。

输出格式

Print one integer — the maximum number of different tuples modulo 109+710^9 + 7.

输出一个整数——模 109+710^9 + 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]a = [1, 1, 1, 1], b=[1,1,1,1]b = [1, 1, 1, 1], x=[0,0,0,0]x = [0, 0, 0, 0], then fi(k)=k mod pif_i^{(k)} = k \bmod p_i.

In the second example we can choose next parameters: a=[1,1,2]a = [1, 1, 2], b=[1,1,0]b = [1, 1, 0], x=[0,0,1]x = [0, 0, 1].

在第一个例子中,我们可以选择以下参数:a=[1,1,1,1]a = [1, 1, 1, 1],b=[1,1,1,1]b = [1, 1, 1, 1],x=[0,0,0,0]x = [0, 0, 0, 0],此时有 fi(k)=k mod pif_i^{(k)} = k \bmod p_i。

在第二个例子中,我们可以选择以下参数:a=[1,1,2]a = [1, 1, 2],b=[1,1,0]b = [1, 1, 0],x=[0,0,1]x = [0, 0, 1]。

输入解题思路,AI测评打分。不知道怎么写?

首页