Problem:


Score : 300 points

Problem Statement

We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.

Initially, the hand of every clock stands still, pointing directly upward.

Now, Dolphin starts all the clocks simultaneously.

In how many seconds will the hand of every clock point directly upward again?

Constraints

1≤N≤100 

1≤T_i≤10^{18} 

All input values are integers.  

The correct answer is at most 10^{18} seconds.

Input

Input is given from Standard Input in the following format:  

N
T_1
:  
T_N

Output

Print the number of seconds after which the hand of every clock point directly upward again.

Sample Input 1

2
2
3

Sample Output 1

6

We have two clocks. The time when the hand of each clock points upward is as follows:

Clock 1: 2, 4, 6, ... seconds after the beginning

Clock 2: 3, 6, 9, ... seconds after the beginning

Therefore, it takes 6 seconds until the hands of both clocks point directly upward.

Sample Input 2

5
2
5
10
1000000000000000000
1000000000000000000

Sample Output 2

1000000000000000000



Sample input:
2
2
3


Sample output:
6

Submission status: Accepted

Solution code:
import math


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


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


N = int(input())
T = []

for _ in range(N):
    T.append(int(input()))

ans = T[0]

for t in T:
    ans = lcm(ans, t)

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
N=int(input())
T=[int(input()) for i in range(N)]
ans=1
for t in T:
    ans=lcm(ans,t)
print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
#from math import gcd
from functools import reduce

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

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

n = int(input())
times = [int(input()) for i in range(n)]

print(lcm(times))

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//gcd(a,b)*b
    
n = int(input())
ans=1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
    
print(ans)

Submission status: Accepted

Solution code:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
        
def lcm(a,b):
    return b * a//gcd(a,b)
    
n = int(input())
ans=1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
    
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)
def gcd(n1,n2):
    if n1 > n2:
        n1,n2 = n2,n1
    if n2 % n1 == 0:return n1
    else: return gcd(n2%n1,n1)
n = int(input())
if n == 1:
    print(int(input()))
    sys.exit()
t = [int(input()) for i in range(n)]
check = t[0]*t[1]//gcd(t[0],t[1])
for i in range(n-2):
    check = (check*t[i+2])//gcd(check,t[i+2])
print(int(check))

Submission status: Accepted

Solution code:
import fractions
n= int(input())
ans = 1
for i in range(n):
 tmp = int(input())
 ans =  (ans*tmp)//fractions.gcd(ans,tmp)
  
print(ans)

Submission status: Accepted

Solution code:
def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

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

N=int(input())
ans=1
for i in range(N):
    ans=lcm(ans,int(input()))
print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())

def gcd(a,b):
    if a > b:
        a,b = b,a
    # a <= b
    while a > 0:
        a,b = b%a, a
    return b

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

x = 1
for i in range(n):
    ti = int(raw_input())
    x = lcm(x, ti)

print x

Submission status: Accepted

Solution code:
def gcd(a, b):
    sm = min(a, b)
    la = max(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la % sm)


N = int(input())
A = [int(input()) for _ in range(N)]

ans = 1
for a in A:
    ans = a * ans // gcd(a, ans)
print(ans)

Submission status: Accepted

Solution code:
def gcm(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(c,d):
  return c*d//gcm(c,d)
N=int(input())
j=int(input())
for i in range(N-1):
  k=int(input())
  j=lcm(j,k)
print(j)

Submission status: Accepted

Solution code:
N = int(input())
ans = 1

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

for i in range(N):
    t = int(input())
    tmp = gcd(ans, t)
    ans = ans * t // tmp
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

#最大公約数
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

#最小公倍数
def lcm(x,y):
    return x*y//gcd(x,y)

ans=a[0]
for i in a:
    ans=lcm(ans,i)
    
print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
n = int(input())
t = []


for _ in range(n):
    t.append(int(input()))


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


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


print(lcm_list(*t))

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]


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


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


if N == 1:
    print(T[0])
    exit()

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)

Submission status: Accepted

Solution code:
#最大公約数
def gcd(a,b):
    if a==b:
        return b
    elif a%b == 0:
        return b
    else:
        return gcd(b,a%b)
def lcd(a,b):
    gc = gcd(a,b)
    return (a*b)//gc
N = int(input())
t = []
num = 1
lc = 1
for i in range(N):
    tmp = int(input())
    if tmp not in t:
        t.append(tmp)
t.sort()
for i in range(len(t)):
    tmp = lc
    lc = lcd(t[i],tmp)
print(lc)

Submission status: Accepted

Solution code:
def abc070_c():
    from fractions import gcd
    n = int(input())
    t = [int(input()) for _ in range(n)]
    ans = t[0]
    for v in t:
        ans = ans * v // gcd(ans, v)

    print(ans)


abc070_c()

Submission status: Accepted

Solution code:
def kouyaku(a,b):
    aa = max(a,b)
    bb = min(a,b)
    if bb == 0:
        return aa
    else:
        return kouyaku(bb,aa%bb)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()

ans = T[0]
for time in T:
    kou = kouyaku(ans, time)
    if kou != time:
        ans = ans//kou * time
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

result = []
x = 1
for i in range(N):
  T = int(input())
  x = x * T // gcd(x, T)
  result.append(x)
print(max(result))

Submission status: Accepted

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

ans = 1
for _ in range(int(input())):
    t = int(input())
    ans = ans * t // gcd(ans, t)
print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y): return x * y // gcd(x, y)
N, *T = map(int, open(0).read().split())
print(reduce(lcm, T))

Submission status: Accepted

Solution code:
from fractions import gcd
a=int(input())
s=int(input())
k=s
for i in range(a-1):
    d=int(input())
    k=(k*d)//gcd(k,d)
print(k)

Submission status: Accepted

Solution code:
from functools import reduce

n = int(input())

t = [int(input()) for _ in range(n)]

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

t.sort()

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

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

print(lcm_list(t))

Submission status: Accepted

Solution code:
from functools import reduce
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 * b // gcd(a, b)

N = int(input())
T = [int(input()) for _ in range(N)]

print(reduce(lcm, T))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)#数列に対しての最小公倍数
n = int(input())
t=[]
for i in range(n):
    t.append(int(input()))
print(lcm(*t))

Submission status: Accepted

Solution code:
n = int(input())
t_list = [int(input()) for _ in range(n)]


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


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


r = 1
for i in range(n):
    r = lcm(r, t_list[i])
print(r)

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]

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

T.sort()
time = T[0]
for i in range(1,N):
    time *= T[i] // gcd(T[i], time)
print(time)

Submission status: Accepted

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


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


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from fractions import gcd
N = int(input())

ans = int(input())
for _ in range(N-1):
    t = int(input())
    g = gcd(t, ans)
    ans = ans*t//g
print(ans)

Submission status: Accepted

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


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
_sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    _sum = lcm(_sum, t[i])
    # print(sum)
print(_sum)

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
 
N = int(input())
A = [int(input()) for i in range(N)]
 
ans = A[0]
 
for i in A:
    ans = (ans*i)//gcd(ans, i)
print(ans)

Submission status: Accepted

Solution code:
import fractions as fr
n = int(input())
t = [int(input()) for _ in range(n)]
ans = 1
for i in range(n):
	ans = ans // fr.gcd(ans, t[i]) * t[i]
print(ans)

Submission status: Accepted

Solution code:
import fractions
def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)
n=int(input())
if n>1:
  x=lcm(int(input()),int(input()))
  for i in range(n-2):
    x=lcm(x,int(input()))
  print(x)
else:print(int(input()))

Submission status: Accepted

Solution code:
#import math
from functools import reduce

n = int(input())
a = [int(input()) for _ in range(n)]

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

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

def lcm(nums):
    #3つ目は初期値
    return reduce(lcm_base, nums, 1)

print(lcm(a))

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
N = int(input())
T = [int(input()) for i in range(N)]
def lcm(x,y):
    return (x * y) // gcd(x,y)
ans = reduce(lcm,T)
print(ans)

Submission status: Accepted

Solution code:
import fractions
N=int(input())
LCM=int(input())
for i in range(N-1):
    T=int(input())
    LCM=LCM*T//fractions.gcd(LCM,T)
print(LCM)

Submission status: Accepted

Solution code:
N=int(input())
l=[]
for i in range(N):
    l.append(int(input()))
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(l))

Submission status: Accepted

Solution code:
import itertools
import math


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


def lcm(left, right):
    return (left * right) // gcd(left, right)


N = int(input().strip())
Ts = []
for i in range(N):
    Ts.append(int(input().strip()))

res = 0
if len(Ts) == 0:
    res = 0
elif len(Ts) == 1:
    res = Ts[0]
else:
    res = int(lcm(Ts[0], Ts[1]))
    for T in Ts[2:]:
        res = int(lcm(res, T))

print(str(int(res)))

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())
T = [int(input()) for i in range(N)]

ans = T[0]

for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Submission status: Accepted

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

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

N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]

for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

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

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

res = int(input())
for _ in range(n-1):
    t = int(input())
    res = lcm(res,t)

print(res)

Submission status: Accepted

Solution code:
N = int(input())
ans = int(input())


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


for i in range(N-1):
    x = int(input())
    g = gcd(ans, x)
    ans *= x
    ans //= g
print(ans)

Submission status: Accepted

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

#from math import gcd
num_clock = int(input())
times = [int(input()) for i in range(num_clock)]
spent_time = times[0]
for time in times[1:]:
    spent_time = (spent_time * time) // gcd(spent_time, time)
print(spent_time)

Submission status: Accepted

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

if __name__ == '__main__':
    n = int(input())
    num_list = [int(input()) for _ in range(n)]
    a = num_list[0]

    for idx in range(1,len(num_list)):
        b = euclidean(a,num_list[idx])
        a = a*num_list[idx]//b
    print(a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from functools import reduce

n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]

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

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

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

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

#print(lcm(27, 18, 9, 3))
# 54

#print(lcm(27, 9, 3))
# 27

#print(lcm(*[27, 9, 3]))
# 27

print(lcm_list(t))

Submission status: Accepted

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

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

ans = A[0]

for i in A:
    ans = (ans*i)//gcd(ans, i)
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
    
def lcm(x,y):
	return (x * y) // gcd(x, y)

ct = 1
for _ in range(n):
	t = int(input())
	ct = lcm(ct,t)
	
print(ct)

Submission status: Accepted

Solution code:
# 最大公約数
def gcd(m, n):
    while(n != 0):
        temp = n
        n = m % n
        m = temp
    return m


N = int(input())
T = [int(input()) for _ in range(N)]
ans = 0
for i in range(len(T)):
    if ans == 0:
        ans = T[i]
    else:
        ans = ans // gcd(ans, T[i]) * T[i]
print(ans)

Submission status: Accepted

Solution code:
def gcd(a,b):
  if a<b:
    a,b=b,a
  while b>0:
    a,b=b,a%b
  return int(a)
N=int(input())
T=1
for i in range(N):
  ti=int(input())
  T=T*ti//gcd(T,ti)
print(T)

Submission status: Accepted

Solution code:
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 
	
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = prenum // gcd(prenum, T) * T
	prenum = lcm
print(lcm)

Submission status: Accepted

Solution code:
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()


def gcd(a, b):
    while (b != 0):
        tmp = a
        a = b
        b = tmp % b

    return a


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


ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)
    # print(ans)

print(ans)

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
N = int(input())
ans = 1
for i in range(0,N):
    t = int(input())
    ans = t * ans // gcd(ans, t)
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(a, b):
    return a * b // gcd(a, b)

def lcmm(*args):
    return reduce(lcm, args)

N = int(input())
T = [0] * N
syuki = 0
for i in range(N):
    T[i] = int(input())
syuki = lcmm(*T)
print(syuki)

Submission status: Accepted

Solution code:
import sys
fin = sys.stdin.readline


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


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


N = int(fin())
T_list = [int(fin()) for _ in range(N)]

if N == 1:
    print(T_list[0])
else:
    common_lcm = lcm(T_list[0], T_list[1])
    for T in T_list[1:]:
        common_lcm = lcm(common_lcm, T)
    print(common_lcm)

Submission status: Accepted

Solution code:
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

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


while n > 1:
    i = 0
    next = []
    if n % 2 == 1:
        next.append(t[n-1])
        n -= 1
    while i < n:
        next.append(lcm(t[i], t[i + 1]))
        i += 2
    t = [] + next
    n = len(t)

print(t[0])

Submission status: Accepted

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

N = int(input())
ans = 1

for i in range(0,N):
    t = int(input())
    ans = t * ans // gcd(ans, t)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]
#P = list(set(T))

def gcd(a,b) :
    a,b = min(a,b),max(a,b)
    while b > 0 :
        a,b = b, a%b
    return a

def lcm(a,b) :
    return a*b//gcd(a,b)
if N == 1 :
    ans = T[0]
else :
    for i in range(len(T)) :
        if i == 0 :
            ans = lcm(T[i],T[i+1])
        else :
            ans = lcm(T[i],ans)
print(ans)

Submission status: Accepted

Solution code:
def euclid(A,B):

    big = max(A,B)
    small = min(A,B)

    r = big % small
    while r != 0:
        big = small
        small = r
        r = big % small
    
    return small


def LCM(A,B):
    return A*B//euclid(A,B)
    

N = int(input())

time = 1
for i in range(N):
    T = int(input())
    time = LCM(time,T)

print(time)

Submission status: Accepted

Solution code:
# encoding: utf-8
N = int(input())
T = [int(input()) for i in range(N)]

T.sort()

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

a = T[0]
for Ti in T[1:]: a = a * Ti // gcd(Ti, a)

print(a)

Submission status: Accepted

Solution code:
def solve(N, As):
    n = 1

    def gcd(a, b):
        a, b = min(a, b), max(a, b)
        while a > 0:
            a, b = b % a, a
        return b

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

    for a in As:
        n = lcm(a, n)
    return n


if __name__ == "__main__":
    N = int(input())
    As = [int(input()) for _ in range(N)]
    print(solve(N, As))

Submission status: Accepted

Solution code:
a=[]
N = int(input())
for i in range(N):
    a.append(int(input().strip()))


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

if N!=1:
    for i in range(len(a)-1):
        pr=a[i]*a[i+1]
        lcm=pr//gcd(a[i],a[i+1])
        a[i+1]=lcm
else:
    lcm=a[0]

print(lcm)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())


# 最大公約数
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a


# 最小公倍数
def lcm(a, b):
    return a*b//gcd(a, b)


array = []
for _ in range(N):
    array.append(int(input()))

ans = array[0]
for x in array[1:]:
    ans = lcm(ans, x)


print(ans)

Submission status: Accepted

Solution code:
n = int(input())

def mnd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return mnd(b, mod)

nd = int(input())
for _ in range(n - 1):
    tmp  = int(input())
    kouyaku = mnd(max(nd, tmp), min(nd, tmp))
    nd = nd * tmp // (kouyaku)
print(nd)

Submission status: Accepted

Solution code:
import sys
def 解():
    iN = int(sys.stdin.readline())
    aT = [int(_) for _ in sys.stdin.readlines()]
    #公倍数を求めるだけ
    def fgcd(a,b):
        while b:
            a,b = b, a%b
        return a

    lcm = aT[0]
    for a in aT[1:]:
        lcm = lcm * a // fgcd(lcm,a)
    print(lcm)
解()

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]
result = T[0]

for i in range(1, N):
    n = T[i]
    m = result
    while n % m != 0:
        m, n = n%m, m
    result = (result * T[i]) // m

print(result)

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = int(input())
lc = 1
for i in range(n):
    t = int(input())
    lc = lc * t // gcd(lc,t)
print(lc)

Submission status: Accepted

Solution code:
N = int(input())
T = sorted([int(input()) for i in range(N)])

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

if N == 1:
    print(T[0])
else:
    ans = T[0]
    for i in range(1, N):
        ans = (ans*T[i])//(gcd(ans, T[i]))
    
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [ int(input()) for i in range(N)]

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

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

x = L[0]
for i in range(len(L)-1):
    y = lcm(x, L[i+1])
    x = y
    
print(x)

Submission status: Accepted

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

N = int(input())
ans = 1
for _ in range(N):
    A = int(input())
    ans = ans*A//gcd(ans,A)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
T = []
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

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

for i in range(N):
    T += [int(input())]
if len(T) == 1:
    print(T[0])
else:
    prev = T[0]
    for i in range(N-1):
        new = T[i+1]
        prev = lcm(prev, new)
    print(prev)

Submission status: Accepted

Solution code:
import fractions
n=int(input())
ans=1
for i in range(n):
  t=int(input())
  ans=ans*t//fractions.gcd(ans, t)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
def gcd(a, b):
  if b==0:
    return a
  else:
    return gcd(b, a%b)
for i in range(n):
  t=int(input())
  ans=ans*t//gcd(ans, t)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

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

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
	return (a * b // gcd(a, b))

N = int(input())
t = int(input())
for i in range(N-1):
	T = int(input())
	t = lcm(t,T)
print(t)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
Tn = []
for _ in range(N):
    Tn.append(int(input()))

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

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

ans = 0
for T in Tn:
    if ans > 0:
        ans = lcm(ans,T)
    else:
        ans = T

print(ans)

Submission status: Accepted

Solution code:
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)

Submission status: Accepted

Solution code:
def LCM(a, b):
    s = a * b
    a, b = min(a, b), max(a, b)
    while a % b > 0:
        a, b = b, a % b
    return s // b

N = int(input())
ans = int(input())
for i in range(N-1):
    ans = LCM(ans, int(input()))
print(ans)

Submission status: Accepted

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

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

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for _ in range(N)]
  
 # 最大公約数
def gcd(a, b):
   while b > 0:
      a, b = b, a%b
   return a
  
 # 最小公倍数
def lcm(a, b):
   return a*b//gcd(a, b)
  
 # 逐次的にlcmを計算する
ans = T[0]
for i in range(N):
    ans = lcm(ans, T[i])
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
T=[int(input()) for i in range(n)]


def euclid(a,b):
  r = a % b
  return euclid(b,r) if r else b

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

num = T[0]
for i in range(1,n):
  num = lcm(num, T[i])
print(num)

Submission status: Accepted

Solution code:
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))


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


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


num = T[0]
for i in range(1, N):
    num = lcm(num, T[i])

print(num)

Submission status: Accepted

Solution code:
import fractions
s = 1
for _ in [0]*int(input()):
  x = int(input())
  s = s*x//fractions.gcd(s,x)
print(s)

Submission status: Accepted

Solution code:
import math
class MathAlgo(object):

    @classmethod
    def gcd(cls, a, b):
        if b == 0:
            return a
        else:
            return cls.gcd(b, a%b)

    @classmethod
    def lcm(cls, a, b):
        return a // cls.gcd(a, b) * b

N = int(input())
ans = int(input())
for i in range(N-1):
    ans = MathAlgo.lcm(ans, int(input()))
print(ans)

Submission status: Accepted

Solution code:
import fractions

n = int(input())
s = []
for i in range(n):
	s.append(int(input()))
x = 1
for i in range(n):
	x = x*s[i]//fractions.gcd(x,s[i])
print(x)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

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

lcm = 1
for i in T:
    lcm = int(lcm * i // gcd(lcm, i))

print(lcm)

Submission status: Accepted

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

N = int(input())
T = [int(input()) for _ in range(N)]
lcm = 1
for t in T:
    lcm = lcm * t // gcd(lcm, t)
print(lcm)

Submission status: Accepted

Solution code:
import fractions

N = int(input())
T = [int(input()) for i in range(N)]

LCM = 1
for i in range(N):
    lcm = (T[i] * LCM) // (fractions.gcd(T[i], LCM))
    LCM = lcm

print(LCM)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a,b):#gcd :: greatest common divisor(最大公約数) :: G
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(X,Y):#lcm :: least common multiple(最小公約数)) :: L
    return X*Y // gcd(X,Y) # XY = GL

ans = 1

for t in T:
    ans = lcm(ans, t)
print(ans)

Submission status: Accepted

Solution code:
import sys
from functools import reduce

stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def get_gcd(a:int, b:int) -> int:
    while b:
        a, b = b, a % b
    return a
    
def get_lcm(a:int, b:int) -> int:
    return (a // get_gcd(a,b)) * b


n = ni()
t = [ni() for _ in range(n)]

lcm = reduce(get_lcm, t)

print(lcm)

Submission status: Accepted

Solution code:
def gcd(x,y):
    if x < y:
        (x,y) = (y,x)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x


n = int(input())
list_t = []
for i in range(n):
    list_t.append(int(input()))
g = list_t[0]
l = list_t[0]
for i in range(1,n):
    g = gcd(l,list_t[i])
    l = (l*list_t[i]) // g

print(l)

Submission status: Accepted

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)

n = int(input())
t = ils(n)
ans = t[0]
for i in t[1:]:
    ans = ans * i // gcd(ans, i)
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

Submission status: Accepted

Solution code:
n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))
    
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

ans = t[0]
for i in t[1:]:
    ans = ans*i//gcd(ans, i)
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = [int(input()) for i in range(n)]

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

def lcm(a, b):
    g = gcd(a, b)
    g_a = a // g
    g_b = b // g
    return g_a * g_b * g

ans = t[0]
for i in range(n-1):
    ans = lcm(ans, t[i+1])

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
   
from functools import reduce

# gcdを求める
def findGCD(a:int, b:int) -> int:
    # ユークリッドの互除法
    while 1:
        if a%b == 0:
            return b
        else:
            a = a%b
        
        if b%a == 0:
            return a
        else:
            b = b%a
                
# lcmを求める
def findLCM(a:int, b:int) -> int:

    return (a//findGCD(a,b)) * b


n = ni()
ts = [ni() for _ in range(n)]

lcm = reduce(findLCM,ts)

print(lcm)

Submission status: Accepted

Solution code:
import fractions
N = int(input())
T = [int(input()) for i in range(N)]

lcm = 1
for t in T:
    lcm = lcm * t // fractions.gcd(lcm,t)
print(lcm)

Submission status: Accepted

Solution code:
#python3.4以前はfractionsにgcdがある
#lcm（最小公倍数）はa*b/gcd(a,b)
import fractions
n=int(input()) 
t=[int(input()) for _ in range(n)]
ans=t[0]

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