CF1349A.Orac and LCM

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

For the multiset of positive integers s={s1,s2,,sk}s=\{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<j}t=\{\textrm{lcm}(\{a_i,a_j\})\ |\ i<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.

输入格式

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

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

输出格式

Print one integer: gcd({lcm({ai,aj})  i<j})\gcd(\{\textrm{lcm}(\{a_i,a_j\})\ |\ 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}t=\{\textrm{lcm}(\{1,1\})\}=\{1\} , so gcd(t)=1\gcd(t)=1 .

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

首页