CF1349A.Orac and LCM

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For the multiset of positive integers s=s1,s2,…,sks={s_1,s_2,\dots,s_k}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of ss as follow:

  • gcd⁡(s)\gcd(s) is the maximum positive integer xx, such that all integers in ss are divisible on xx.
  • lcm(s)\textrm{lcm}(s) is the minimum positive integer xx, that divisible on all integers from ss.

For example, gcd⁡(8,12)=4,gcd⁡(12,18,6)=6\gcd({8,12})=4,\gcd({12,18,6})=6 and lcm(4,6)=12\textrm{lcm}({4,6})=12. Note that for any positive integer xx, gcd⁡(x)=lcm(x)=x\gcd({x})=\textrm{lcm}({x})=x.

Orac has a sequence aa with length nn. He come up with the multiset t=lcm(ai,aj) ∣ i<jt={\textrm{lcm}({a_i,a_j})\ |\ i \lt j}, and asked you to find the value of gcd⁡(t)\gcd(t) for him. In other words, you need to calculate the GCD of LCMs of all pairs of elements in the given sequence.

对于正整数多重集 s={s1,s2,…,sk}s = \{s_1, s_2, \dots, s_k\},定义 ss 的**最大公约数(GCD)和最小公倍数(LCM)**如下:

  • gcd⁡(s)\gcd(s) 是最大的正整数 xx,使得 ss 中所有整数均能被 xx 整除;
  • lcm(s)\textrm{lcm}(s) 是最小的正整数 xx,使得 xx 能被 ss 中所有整数整除。

例如:gcd⁡({8,12})=4\gcd(\{8,12\}) = 4,gcd⁡({12,18,6})=6\gcd(\{12,18,6\}) = 6,lcm({4,6})=12\textrm{lcm}(\{4,6\}) = 12。注意:对任意正整数 xx,均有 gcd⁡({x})=lcm({x})=x\gcd(\{x\}) = \textrm{lcm}(\{x\}) = x。

Orac 有一个长度为 nn 的序列 aa。他构造了多重集 t={lcm(ai,aj)∣i<j}t = \{\textrm{lcm}(a_i, a_j) \mid i < j\},并请你帮他求出 gcd⁡(t)\gcd(t) 的值。换言之,你需要计算给定序列中所有元素对的最小公倍数所构成集合的最大公约数。

输入格式

The first line contains one integer n (2≤n≤100 000)n\ (2\le n\le 100\,000).

The second line contains nn integers, a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤200 0001 \leq a_i \leq 200\,000).

第一行包含一个整数 n (2≤n≤100 000)n\ (2\le n\le 100\,000)。

第二行包含 nn 个整数:a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤200 0001 \leq a_i \leq 200\,000)。

输出格式

Print one integer: gcd⁡(lcm(ai,aj) ∣ i<j)\gcd({\textrm{lcm}({a_i,a_j})\ |\ i \lt j}).

输出一个整数:gcd⁡(lcm(ai,aj) ∣ i<j)\gcd({\textrm{lcm}({a_i,a_j})\ |\ i \lt j})。

输入输出样例

  • 输入#1

    2
    1 1

    输出#1

    1
  • 输入#2

    4
    10 24 40 80

    输出#2

    40
  • 输入#3

    10
    540 648 810 648 720 540 594 864 972 648

    输出#3

    54

说明/提示

For the first example, t=lcm(1,1)=1t={\textrm{lcm}({1,1})}={1}, so gcd⁡(t)=1\gcd(t)=1.

For the second example, t=120,40,80,120,240,80t={120,40,80,120,240,80}, and it's not hard to see that gcd⁡(t)=40\gcd(t)=40.

对于第一个例子,t=lcm(1,1)=1t={\textrm{lcm}({1,1})}={1},因此 gcd⁡(t)=1\gcd(t)=1。

对于第二个例子,t=120,40,80,120,240,80t={120,40,80,120,240,80},不难看出 gcd⁡(t)=40\gcd(t)=40。

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

首页