原题链接
考察:推公式
思路:

\[gcd(lcm(a,b),lcm(a,c))==gcd(a,lcm(b,c)) \]

Code

#include <iostream> 
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 100010;
int a[N],n,R[N];
LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}
LL lcm(LL a,LL b)
{
	return (LL)a*b/gcd(a,b);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=n;i>=1;i--) R[i] = gcd(R[i+1],a[i]);
	LL res= 0;
	for(int i=1;i<=n;i++)
	{
		LL t = lcm(a[i],R[i+1]);
		res = gcd(res,t);
	}
	printf("%lld\n",res);
	return 0;
}