CF1349A.Orac and LCM
普及/提高-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For the multiset of positive integers s=s1,s2,…,sk, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:
- gcd(s) is the maximum positive integer x, such that all integers in s are divisible on x.
- lcm(s) is the minimum positive integer x, that divisible on all integers from s.
For example, gcd(8,12)=4,gcd(12,18,6)=6 and lcm(4,6)=12. Note that for any positive integer x, gcd(x)=lcm(x)=x.
Orac has a sequence a with length n. He come up with the multiset t=lcm(ai,aj) ∣ i<j, and asked you to find the value of 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 的**最大公约数(GCD)和最小公倍数(LCM)**如下:
- gcd(s) 是最大的正整数 x,使得 s 中所有整数均能被 x 整除;
- lcm(s) 是最小的正整数 x,使得 x 能被 s 中所有整数整除。
例如:gcd({8,12})=4,gcd({12,18,6})=6,lcm({4,6})=12。注意:对任意正整数 x,均有 gcd({x})=lcm({x})=x。
Orac 有一个长度为 n 的序列 a。他构造了多重集 t={lcm(ai,aj)∣i<j},并请你帮他求出 gcd(t) 的值。换言之,你需要计算给定序列中所有元素对的最小公倍数所构成集合的最大公约数。
输入格式
The first line contains one integer n (2≤n≤100000).
The second line contains n integers, a1,a2,…,an (1≤ai≤200000).
第一行包含一个整数 n (2≤n≤100000)。
第二行包含 n 个整数:a1,a2,…,an(1≤ai≤200000)。
输出格式
Print one integer: gcd(lcm(ai,aj) ∣ i<j).
输出一个整数:gcd(lcm(ai,aj) ∣ i<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)=1, so gcd(t)=1.
For the second example, t=120,40,80,120,240,80, and it's not hard to see that gcd(t)=40.
对于第一个例子,t=lcm(1,1)=1,因此 gcd(t)=1。
对于第二个例子,t=120,40,80,120,240,80,不难看出 gcd(t)=40。
输入解题思路,AI测评打分。不知道怎么写?