Problem:


Least Common Multiple

Find the least common multiple (LCM) of given n integers.

Input

n
a1 a2 ... an

n is given in the first line. Then, n integers are given in the second line.

Output

Print the least common multiple of the given integers in a line.

Constraints

2 ≤ n ≤ 10

1 ≤ ai ≤ 1000

Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1

Sample Input 1

3
3 4 6

Sample Output 1

12

Sample Input 2

4
1 2 3 5

Sample Output 2

30



Sample input:
3
3 4 6


Sample output:
12

Submission status: Accepted

Solution code:
import sys
import math


def main2():
    n = int(input())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    lcm = 1
    for a in A:
        lcm = a * lcm // math.gcd(a, lcm)

    print(lcm)


main2()

Submission status: Accepted

Solution code:
from math import gcd
a=1
n=int(input())
l=list(map(int,input().split()))
for i in l:
    a=a*i//gcd(a,i)
print(a)

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(a,n):
    x = a[0]
    for i in range(1,n):
        x = (x * a[i]) // gcd(x,a[i])
    return x
        
n = int(input())
a = list(map(int,input().split()))
print(lcm(a,n))

Submission status: Accepted

Solution code:
import sys
from math import gcd

input = sys.stdin.readline


def lcm(a, b):
    return (a * b) // gcd(a, b)


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 1
    for a in A:
        ans = lcm(ans, a)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
from functools import*
print(reduce(lambda a, b: a * b // math.gcd(a, b), map(int, open(0).read().split()[1:])))

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
  ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions

N = int(input())
data = list(map(int,input().split()))
x = data[0]
for i in range(1, N):
    x = x * data[i] // fractions.gcd(x, data[i])
print(x)

Submission status: Accepted

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
x = a[0]
for i in range(1,n):
    x = x * a[i] // math.gcd(x,a[i])
print(x)

Submission status: Accepted

Solution code:
import math

def main(n):
	ans = 1
	lst = list(map(int, input().split()))
	for i in lst:
		ans = ans * i // math.gcd(ans,i)
	print(ans)
main(int(input()))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

print(lcm(a))

Submission status: Accepted

Solution code:
# 76
import math
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = x * a[i] // math.gcd(x, a[i])
print(x)

Submission status: Accepted

Solution code:
from math import gcd
a = int(input())  
b = list(map(int, input().split())) 
lcm = b[0]  
for m in b[1:]:
    lcm = int((lcm*m)/gcd(lcm, m)) 
print(lcm)

Submission status: Accepted

Solution code:
import math
from functools import reduce
n=int(input())
z=list(map(int,input().split()))
def lcm_b(x,y):
    return (x*y)//(math.gcd(x,y))
def lcm(*z):
    return reduce(lcm_b,z,1)
print(lcm(*z))

Submission status: Accepted

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(1,n):
    b=b*a[i]//math.gcd(b,a[i])
print(b)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
a=list(map(int,input().split()))
x=a[0]
for i in range(1,n):
    x=x*a[i]//fractions.gcd(x,a[i])
print(x)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import math
n = int(input())
b = 1
for a in list(map(int,input().split())):
    b = a*b // math.gcd(a,b)
print(b)

Submission status: Accepted

Solution code:
#76 最小公倍数

import math

def main(n):
	ans = 1
	lst = list(map(int, input().split()))
	for i in lst:
		ans = ans * i // math.gcd(ans,i)
	print(ans)
main(int(input()))

Submission status: Accepted

Solution code:
n=int(input())
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

a = list(map(int,input().split()))
print(lcm(a))

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

N = int(input())
a = list(map(int,input().split()))
f = a[0]

for i in range(1,N):
    f = lcm(f,a[i])

print(f)

Submission status: Accepted

Solution code:
def gcd(a, b) :
    while True :
        if a < b :
            a, b = b, a
        amari = a % b
        if amari == 0 :
            break
        else :
            a, b = b, amari
    return(b)

n = int(input())
c = list(map(int, input().split()))
for i in range(n-1, 0, -1) :
    c[i-1] = int(c[i] * c[i-1] / gcd(c[i], c[i-1]))
print(c[0])

Submission status: Accepted

Solution code:
import fractions

n = int(input())
a = list(map(int, input().split()))
ans = a[0]

for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
lcm=a[0]
for i in range(1,n):
    x=lcm
    y=a[i]
    lcm=(x*y)//math.gcd(x,y)
print(lcm)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
a_s=list(set(a))
while len(a_s)!=1:
    gcd=math.gcd(a_s[-1],a_s[-2])
    lcm=int(a_s[-1]*a_s[-2]/gcd)
    a_s=a_s[:-2]
    a_s.append(lcm)
print(a_s[0])

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
   ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions as fra
n=int(input())
a=list(int(z) for z in input().split())
A=a[0]
for i in range(1,n):
    A=A*a[i]//fra.gcd(A,a[i])
print(A)

Submission status: Accepted

Solution code:
from math import gcd
n = int(input())
k = 1
for x in map(int, input().split()):
    k = k * x // gcd(k, x)
print(k)

Submission status: Accepted

Solution code:
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
l=list(map(int,input().split()))
    
print(reduce(lcm,l))

Submission status: Accepted

Solution code:
import fractions
A=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(A):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
from math import gcd
n = int(input())
a = list(map(int,input().split()))
b = a[0]
for i in a[1:]:
    b = int(b*i/gcd(b, i))
print(b)

Submission status: Accepted

Solution code:
import math
from functools import reduce

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base,numbers,1)

n=int(input())
a=list(map(int,input().split()))
print(lcm_list(a))

Submission status: Accepted

Solution code:
import math
def keisan(x,y):
    z = (x[0]*x[1])//math.gcd(x[0],x[1])
    for i in range(y-2):
        z = (z*x[i+2])//math.gcd(z,x[i+2])
    return z
    
n = int(input())    
a = list(map(int,input().split()))
print(keisan(a,n))

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions

n = int(input())
lst = list(map(int,input().split()))
ans = lst[0]

for i in range(1,n):
    ans = ans * lst[i] // fractions.gcd(ans, lst[i])

print(ans)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
l=list(map(int,input().split()))
a=l[0]
for i in range(1,n):
    a=a*l[i]//fractions.gcd(a,l[i])
print(a)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
l=list(map(int,input().split()))

m=l[0]
for i in range(n):
    m=m*l[i]//fractions.gcd(m,l[i])
print(m)

Submission status: Accepted

Solution code:
from math import gcd
from functools import reduce


def get_LCM(l):
    def lcm(a, b):
        return (a * b) // gcd(a, b)

    return reduce(lcm, l, 1)


if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    print(get_LCM(l))

Submission status: Accepted

Solution code:
import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print(lcm(*(a)))

Submission status: Accepted

Solution code:
import math
n=int(input())
L=list(map(int,input().split()))
print
if n==1:
    print(L[0])
else:
    x=L[0]
    for i in range(1,n):
        x=(x*L[i])//math.gcd(x,L[i])
        i+=1
    print(x)

Submission status: Accepted

Solution code:
# coding: utf-8
# 76

import fractions

n = int(input())

a = list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    ans = ans*a[i] // fractions.gcd(ans,a[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
a=list(map(int,input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
import math
from functools import reduce
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n=int(input())
a=map(int,(input().split()))
print(reduce(lcm,a))

Submission status: Accepted

Solution code:
import fractions

n=int(input())
m=list(map(int,input().split()))
ans = m[0]
for i in range(1,n):
    ans =ans*m[i]//fractions.gcd(ans,m[i])
print(ans)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=ans*a[i] // fractions.gcd(ans,a[i])
print(ans)

Submission status: Accepted

Solution code:
import math
from functools import reduce

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm(*numbers):
    return reduce(lcm_base,numbers,1)
 
x=int(input()) 
a=[int(i) for i in input().split()]

print(lcm(*a))

Submission status: Accepted

Solution code:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans =ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Submission status: Accepted

Solution code:
#L_1_C
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans,a[i])

print(ans)

Submission status: Accepted

Solution code:
#mathモジュールのimportと標準入力
import math
i = int(input())
line = list(map(int,input().split()))

#変数の更新
n = line[0]

#最小公倍数を求めその最小公倍数と新しい数との最小公倍数を求める
for l in range(1,i):n = int(n * line[l] / math.gcd(n,line[l]))

#出力
print(n)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
a=list(map(int, input().split()))
b=a[0]
for i in range(1, n):
    b=b*a[i]//fractions.gcd(b, a[i])
print(b)

Submission status: Accepted

Solution code:
from math import gcd
n = int(input())
a = list(map(int, input().split()))

x = a[0]
for i in range(1,n):
    x = (x*a[i]//gcd(x,a[i]))
    
print(x)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
# nこのlcm 順番に計算するとlog a * n くらいになる？
def my_lcm(a, b):
    cum = a * b
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    # b がgcd になっている
    return cum // b


res = 1
for i in a:
    res = my_lcm(res, i)
print(res)

Submission status: Accepted

Solution code:
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
    b=lcm(b,i)
print(b)

Submission status: Accepted

Solution code:
import math
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

n=int(input())
a=list(map(int,input().split()))

x=lcm(a[0],a[1])
i=2
for i in range(n):
    x=lcm(x,a[i])
    
print(x)

Submission status: Accepted

Solution code:
from functools import reduce

def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def gcd_base(x, y):
    if x % y:
        return gcd_base(y, x%y)
    return y

def gcd(numbers):
    return reduce(gcd_base, numbers)

def lcm_base(x, y):
    res = (x * y) // gcd_base(x, y)
    return res #if res <= 1000000007 else 0 #1000000007を超える場合は0

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = [int(i) for i in input().split()]
print(lcm(a))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
import math
lcm = a[0]
for i in a[1:]:
    lcm = i * lcm // math.gcd(lcm, i)
print(lcm)

Submission status: Accepted

Solution code:
import fractions
n = int(input())

def lcm(a, b):
	return a*b//fractions.gcd(a, b)

a = list(map(int,input().split()))
ans = 1
for i in a:
	ans = lcm(ans, i)
print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
lst=list(map(int,input().split()))

ans=lst[0]
for i in range(1,n):
    ans=ans*lst[i]//math.gcd(ans,lst[i])
print(ans)

Submission status: Accepted

Solution code:
def factrize(x):
    # 試し割りによるxの素因数分解
    f = {}
    tmp = x
    i = 2
    while i**2 <= tmp:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp = tmp // i
        if cnt > 0:
            f[i] = cnt
        i += 1
    if tmp != 1 or f == {}:
        f[tmp] = 1
    return f


n = map(int, input().split())
*A, = map(int, input().split())
A = [factrize(a) for a in A]
F = {}
for f in A:
    for p in f:
        try:
            F[p] = max(F[p], f[p])
        except KeyError:
            F[p] = f[p]
ans = 1
for p in F:
    ans *= p**F[p]
print(ans)

Submission status: Accepted

Solution code:
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
    b=lcm(b,i)
print(b)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

def gcd(x, y):
   if x < y:
      x, y = y, x
   if x % y == 0:
      return y
   else:
      return gcd(y, x % y)

n = int(input())
A = list(map(int, input().split()))

l = A[0]
for i in range(1, n):
   l = l * A[i] / gcd(l, A[i])
print(int(l))

Submission status: Accepted

Solution code:
from itertools import accumulate


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


def LCM(a, b):
    return a // GCD(a, b) * b


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    lcm = 1
    ans = list(accumulate(A, func=LCM))[-1]
    print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

def gcd(m, n):
    if m < n:
        return gcd(n, m)
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

n = int(input())
l = [int(arg) for arg in input().split()]
print(reduce(lcm, l, l[0]))

Submission status: Accepted

Solution code:
from functools import reduce
import math

n = int(input())

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

numlis = [int(a) for a in input().split()]
print(lcm_list(numlis))

Submission status: Accepted

Solution code:
import math
from functools import reduce
n = int(input())
A = tuple(map(int, input().split()))
print(reduce(lambda a, b: a*b // math.gcd(a, b), A))

Submission status: Accepted

Solution code:
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
print(lcm(*map(int, input().split())))

Submission status: Accepted

Solution code:
def gcd(a, b) :
    while True :
        if a < b :
            a, b = b, a
        amari = a % b
        if amari == 0 :
            break
        else :
            a, b = b, amari
    return(b)

n = int(input())
c = list(map(int, input().split()))
for i in range(n-1, 0, -1) :
    c[i-1] = int(c[i] * c[i-1] / gcd(c[i], c[i-1]))
print(c[0])

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = x * a[i] // fractions.gcd(x, a[i])
print(x)

Submission status: Accepted

Solution code:
from math import gcd
a = int(input())  # take amount of number
b = list(map(int, input().split()))  # take all number in an array. Also can be solved without array in c++
lcm = b[0]  # assign first element to lcm
for m in b[1:]:
    lcm = int((lcm*m)/gcd(lcm, m))  # check telegram tutorial to understand this
print(lcm)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
x=list(map(int,input().split()))
ans=x[0]
for i in range(1,n):
    ans=ans*x[i]//fractions.gcd(ans,x[i])
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())
A = [int(a) for a in input().split()]

ans = A[0]

for i in range(1, n) :
    ans = ans * A[i] // math.gcd(ans, A[i])
    
print(ans)

Submission status: Accepted

Solution code:
N=input()
target = list(map(int, input().split()))

def calc_factors(N):
    n = int(N**.5)
    arr = []
    tmp = N
    for i in range(2,n+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp = int(tmp/i)
    if tmp != 1: arr.append(tmp) 
    return arr

d = {}
for i in target:
    arr = calc_factors(i)
    for a in set(arr):
        if a in d.keys():
            d[a] = max(d[a], arr.count(a))
        else:
            d[a] = arr.count(a)
res = 1
for k,v in d.items():
    res*=(int(k)**int(v))
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# A = list(map(int,sys.stdin.readline().split()))
# A = [sys.stdin.readline() for _ in range(N)]
# A = [list(map(int,sys.stdin.readline())) for _ in range(N)]
# A = [int(sys.stdin.readline()) for _ in range(N)]
# S = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
import sys,bisect,math
from functools import reduce
sys.setrecursionlimit(15000)

N = int(sys.stdin.readline())
A = list(map(int,sys.stdin.readline().split()))

def lcm(x,y):
  return x*y // math.gcd(x,y)

print(reduce(lcm,A))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)


tmp = lcm(a[0], a[1])
for i in range(2, n):
	tmp = lcm(tmp, a[i])

print(tmp)

Submission status: Accepted

Solution code:
import math

n=int(input())
a=list(map(int,input().split()))
def lcm(a,b):
    return a*b/math.gcd(a,b)
ans=int(lcm(a[0],a[1]))
for i in range(2,len(a)):
    ans=int(lcm(ans,a[i]))
print(int(ans))

Submission status: Accepted

Solution code:
def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
a = list(map(int,input().split()))
f = a[0]

for i in range(1,N):
    f = lcm(f,a[i])

print(f)

Submission status: Accepted

Solution code:
n=int(input())
*a,=map(int, input().split())

def gcd(a,b):
    while b: a,b=b,a%b
    return a

def lcm(a,b): return a*b//gcd(a,b)

ans = 1
for ai in a:
    ans = lcm(ans, ai)
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    # saisyou koubaisuu
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm, numbers)

n = int(input())
a = list(map(int, input().split()))

print(lcm_list(a))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))

def elements(dim):
    ans = []
    cnt = 2
    while cnt <= dim:
        if dim % cnt == 0:
            dim //= cnt
            ans.append(int(cnt))
            cnt = 2
        else:
            cnt += 1
    return ans

l_e = []

for i in l:
    i_e = elements(i)
    for j in i_e:
        if j in l_e:
            l_e.remove(j)
    l_e += i_e

out = 1
for i in l_e:
    out *= i
print(out)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
ans = a[0]
for i in range(n-1):
    b = gcd(ans,a[i+1])
    ans *= a[i+1]//b
print(ans)

Submission status: Accepted

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lce(a, b):
    return a * b // gcd(a, b)

N = int(input())
A = [int(i) for i in input().split()]

ans = 1
for b in A:
    ans = lce(ans, b)

print(ans)

Submission status: Accepted

Solution code:
import fractions

n = int(input())
Numbers =list(map(int,input().split()))

def lcm(Numbers):
    N = len(Numbers)
    if N == 1:
        return Numbers[0]
    else:
        Numbers[N-2] = \
        Numbers[N-1]*Numbers[N-2] \
        //fractions.gcd(Numbers[N-1],Numbers[N-2])
        return lcm(Numbers[0:N-1])

print(lcm(Numbers))

Submission status: Accepted

Solution code:
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = a[0]
lcm = 0
for i in range(1, n):
    tmp = gcd(g, a[i])
    lcm = g * a[i] // tmp
    g = lcm
    tmp = lcm
print(lcm)

Submission status: Accepted

Solution code:

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n = int(input())
a = list(map(int,input().split()))
print(lcm(a))

Submission status: Accepted

Solution code:
# 一番小さい値と大きい値を比べるその値と一致していたら、他の数値で試す
def getLCM(num1,num2):
    base1 = num1
    base2 = num2
    while 1:
        if num1 < num2:
            num1 =  num1 + base1
        elif num1 > num2:
            num2 =  num2 + base2
        elif num1 == num2:
            return num1

def getNextLCM(base1,base2,lcm):
    num1 = lcm + base1
    num2 = lcm
    while 1:
        if num1 < num2:
            num1 =  num1 + base1
        elif num1 > num2:
            num2 =  num2 + base2
        elif num1 == num2:
            return num1
while 1:
    try:
        n = int(input())
        numbers = list(int(x) for x in input().split())
    except:break
    
    # 1があったら消す
    if 1 in numbers:
        numbers.remove(1)
    numbers = sorted(numbers)
    reduceIndex = []
    size = len(numbers) - 1
    
    # for i in numbers:
    #     print(str(i) + " ",end="")
    # print()
    
    # 割れたらその数を消す
    while(size > 1):
        isReduce = False
        
        for i in range(size - 1,-1,-1) :
            if numbers[size] % numbers[i] == 0:
                reduceIndex.append(numbers[i])
                isReduce = True
        for i in reduceIndex:
            numbers.remove(i)
        if isReduce:
            size = len(numbers) - 1
            reduceIndex.clear()
        else:
            size = size - 1
            
    # for i in numbers:
    #     print(str(i) + " ",end="")
    # print()
    
    size = len(numbers)
    if size == 1:
        print(numbers[size - 1])
        break
    
    lcm = getLCM(numbers[size - 1],numbers[size - 2])
    
    while(1):
        isFind = True
        for i in range(size - 2,-1,-1):
            # print(i)
            # print(lcm % numbers[i])
            if lcm % numbers[i] != 0:
                i = -1
                isFind = False
 
        if isFind:
            break
        else:
            lcm = getNextLCM(numbers[size - 2],numbers[size - 1],lcm)
    print(lcm)

Submission status: Accepted

Solution code:
from functools import reduce

def gcd(x,y):
    while y:
        x,y = y,x%y
    return x

def lcm(x,y):
    return x//gcd(x,y)*y

N = int(input())
A = list(map(int,input().split()))

print(reduce(lcm,A))

Submission status: Accepted

Solution code:
import math
n = int(input())
r = 1
for i in map(int, input().split()):
	r = r // math.gcd(r,i) * i	
print(r)

Submission status: Accepted

Solution code:
n=int(input())

def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def LCM(a,b):
    return (a*b)//GCD(a,b)

a=[int(i) for i in input().split(" ")]

lcm=1
for ai in a:
    lcm=LCM(ai,lcm)
print(lcm)

Submission status: Accepted

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)
 
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
print(reduce(lcm, a))

Submission status: Accepted

Solution code:
import math

n=int(input())
A=list(map(int,input().split()))
x=1
for a in A:
    x=a*x//math.gcd(a,x)

print(x)

Submission status: Accepted

Solution code:
from math import gcd


def lcm(arr):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret


def aoj():
    N = int(input())
    print(lcm([int(x) for x in input().split()]))


if __name__ == '__main__':
    aoj()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
import math
def lcm(a,b):
	return a*b//(math.gcd(a,b))
ans=1
for i in range(n):
	ans=lcm(ans,a[i])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
def gcd(a,b):
    while b != 0:
        k = b
        b = a%b
        a = k
    return a
g = gcd(max(L[0],L[1]),min(L[0],L[1]))
lcm = L[0]*L[1]//g
for i in range(2,len(L)):
    cur = gcd(max(lcm,L[i]),min(lcm,L[i]))
    if lcm%L[i] == 0:
        None
    elif L[i]%lcm == 0:
        lcm = L[i]
    else:
        lcm = lcm*L[i]//cur
print(lcm)

Submission status: Accepted

Solution code:
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

n = int(input())
Data = list(map(int,input().split()))
ans = lcm(Data[0],Data[1])
for i in range(2,len(Data)):
    ans = lcm(ans,Data[i])
print(ans)

Submission status: Accepted

Solution code:
#C
import math
N = int(input())
A = list(map(int,input().split()))

lcm = 1
for a in A:
    lcm = (lcm*a)//math.gcd(lcm,a)

print(lcm)

Submission status: Accepted

Solution code:
import math
input()
L = list(map(int, input().split()))
m = [ [] for x in range(len(L))]
for i in range(len(L)):
    n = L[i]
    k = n
    for j in range(2, int(math.sqrt(n))+1):
        if j > k:
            break
        while k % j ==0:
            m[i].append(j)
            k = k // j
            if k == 1:
                break
    if k != 1:
        m[i].append(k)
s = set()
for i in m:
    s |= set(i)
lcm = 1
for i in s:
    lcm *= i**max([ m[x].count(i) for x in range(len(L))] )
print(lcm)

Submission status: Accepted

Solution code:
from math import*;n,a=open(0);l=1
for x in map(int,a.split()):l=l*x//gcd(x,l)
print(l)

Submission status: Accepted

Solution code:
def gcd(a, b):
    """a, bの最大公約数(greatest common divisor:GCD)を求める"""
    if b == 0:
        return a
    return gcd(b, a%b)


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
a = list(map(int, input().split()))
print(multi_lcm(a))

Submission status: Accepted

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

n=int(input().rstrip())
a=[int(i) for i in input().split()]
ans=a[0]
for i in range(1,n):
    ans=lcm(ans,a[i])
print(ans)

Submission status: Accepted

Solution code:
import sys
import math

z=input()
n=list(map(int,input().split()))
k={}
L={}

for num in n:
  #yakusu no kazu wo kaesu
  i=num
  j=2
  k.clear()
  while i>1:
    if i%j==0:
      if j in k:
        k[j]+=1
      else:
        k[j]=1
      i/=j
      j=2
    else:
      j+=1
      
  for i in k:
    if i in L:
      if k[i]>L[i]:
        L[i]=k[i]
    else:
      L[i]=k[i]

#print(L)
ans=1
for i in L:
  ans*=i**L[i]

print(ans)

Submission status: Accepted

Solution code:
import copy
import math
from typing import List


def compute_prime_factor(n: int) -> None:
    global prime_factors
    sqrt_n = int(math.sqrt(n)) + 1
    for i in range(2, sqrt_n + 1):
        if 0 == (n % i):
            prime_factors.append(i)
            compute_prime_factor(n // i)
            return
    if 1 != n:
        prime_factors.append(n)
        return


if __name__ == "__main__":
    n = int(input())
    A = list(map(lambda x: int(x), input().split()))

    prime_factor_dict: dict = {}
    for i in range(n):
        prime_factors = []  # type: ignore
        compute_prime_factor(A[i])
        prime_factor_dict[A[i]] = prime_factors

    max_num = max(A)
    all_factors: List[int] = prime_factor_dict[max_num]
    for key, factors in prime_factor_dict.items():
        if key == max_num or key == 1:
            continue
        tmp = copy.deepcopy(prime_factor_dict[max_num])
        for elem in factors:
            if elem in tmp:
                tmp.pop(tmp.index(elem))
            else:
                all_factors.append(elem)

    ans = 1
    for elem in all_factors:
        ans *= elem
    print(ans)

Submission status: Accepted

Solution code:
import math

def lcm(x, y):
    return (x*y) // math.gcd(x, y)

n = int(input())
A = list(map(int, input().split()))
ans = 1

for a in A:
    ans = lcm(ans, a)
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))

lcm = a[0]
for i in range(1, n):
    lcm = (lcm * a[i]) // math.gcd(lcm, a[i])
    
print(lcm)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(li): return reduce(lcm, li, 1)

N = INT()
A = LIST()
print(lcm_list(A))