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:
A = int(input())
a = [input() for i in range(A)]
a = map(int,a)
a = sorted(a)

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

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

for i in range(A-1):
    b=lcm(a[0],a[1])
    del a[0:2]
    a.insert(0,b)
print(a[0])

Submission status: Accepted

Solution code:
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)

n=int(input())
cur=0
if n==1:
    cur=int(input())
else:
    cur=lcm(int(input()),int(input()))
    for _ in range(n-2):
        cur = lcm(int(input()),cur)
print(cur)

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)

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

ans = reduce(lcm, t)
print(ans)

Submission status: Accepted

Solution code:
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
 
N=int(input())
A = [ int(input()) for _ in range(N) ]
ans = A[0]
for x in A[1:]:
  ans = ans * x // gcd(ans, x)
print(ans)

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)]
T.sort()
G=T[0]
for i in range(N):
  G=lcm(G,T[i])
print(G)

Submission status: Accepted

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

T = sorted(T)
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

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

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

print(LCM)

Submission status: Accepted

Solution code:
import decimal


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


def lcm(a, b):
    g = euclid(a, b)
    # print(g)
    # print(a * b)

    return a * b // g


if __name__ == '__main__':
    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):
    m = max(a,b)
    n = min(a,b)
    if n==0:
        return m
    return gcd(n, m%n)

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

N = input()
Ti = []

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))

ans_lcm = 1
for i in range(len(Ti)):
    ans_lcm = lcm(ans_lcm,Ti[i])
print(ans_lcm)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def gcd(t, n):
    if n == 0:
        return t
    return gcd(n, t%n)


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce
N = int(input())
ary = []
for i in range(N):
    tmp = input()
    ary.append(int(tmp))


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)


print(reduce(LCM, ary))

Submission status: Accepted

Solution code:
#coding=UTF-8
#import math
import fractions

N=int(input())
ans=1
for idx in range(0,N,1):
    T=int(input())
    ans=ans*T// fractions.gcd(ans,T)

print(ans)

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

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

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)
    
def main():
    N = int(input())
    T = []

    for i in range(N):
        T.append(int(input()))
    
    while len(T) > 1:
        T_tmp = []
        for i in range(1, len(T)):
            tmp = lcm(T[i-1], T[i])
            T_tmp.append(tmp)
        T = T_tmp
    
    print(T[0])
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

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

Submission status: Accepted

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

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

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))

Submission status: Accepted

Solution code:
from functools import reduce

def gcd(*numbers):
    from fractions import gcd
    return reduce(gcd, numbers)

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

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

a = t_list[0]
for c in range(N-1):
	b = t_list[c+1]
	a =a*b//gcd(a,b)

print(a)

Submission status: Accepted

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

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

n = int(raw_input())
l = [int(raw_input()) for _ in range(n)]
print reduce(lcm, l)

Submission status: Accepted

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

n = int(input())

res = 1
for i in range(n):
    a = int(input())
    g = gcd(res, a)
    res = (res // g) * a

print(res)

Submission status: Accepted

Solution code:
import fractions
import numpy as np


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

def main():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    res = 1
    for e in T:
        res = lcm(res, e)
    print(res)

if __name__ == '__main__':
    main()

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 = input()
t = []
for i in range(n):
    t.append(input())

key = t.pop(0)

while len(t) != 0:
    b = t.pop(0)
    key = lcm(key, b)

print key

Submission status: Accepted

Solution code:
import fractions
import functools

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

n=int(input())
t=[]
for i in range(n):
	t.append(int(input()))
ans=functools.reduce(lcm,t)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a,b):
    if(a == 0):
        return b
    else:
        return gcd(b % a, a)
    
def lcmm(l,m):

    prod = l * m

    gcD = gcd(l,m)

    return (prod // gcD)

n = int(input().strip())

lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)

Submission status: Accepted

Solution code:
import fractions

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

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 calc(A,B):
    C = A * B
    while B != 0:
        A,B = B, A % B
    return C // A
    
N = int(input())
ans = 1
for i in range(N):
    ans = calc(ans, int(input()))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
li = []
 
for i in range(n):
    a = int(input())
    li.append(a)
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
while len(li) > 1:
    a = li[0]
    b = li[1]
    li.pop(1)
    li.pop(0)
    ans = a * b // gcd(a, b)
    li.append(ans)
 
print(li[0])

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
def euc(a,b):
    if b == 0:
        return a
    else:
        return euc(b, a%b)

N = int(input())
T = [ int(input()) for tmp in range(N) ]
if len(T) > 1:
    a = T.pop()
    b = T.pop()
    lcm = a*b//euc(a,b)
    for tmp in T:
        lcm = tmp*lcm//euc(tmp,lcm)
    print(lcm)
else:
    print(T.pop())

Submission status: Accepted

Solution code:
'''
def gcd(a,b):
    if a<b:
     c=a
     a=b
     b=c

    c=a%b

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

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

def lcm(e,f):
    c=gcd(e,f)
    g=e*f
    return g//c



n=int(input())
t=[0]*n

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

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Accepted

Solution code:
'''
def gcd(a,b):
    if a<b:
     c=a
     a=b
     b=c

    c=a%b

    if c==0:
     return b
    else:
     return gcd(b,c)
'''

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

def lcm(e,f):
    c=gcd(e,f)
    g=e*f
    return g//c



n=int(input())
t=[0]*n

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

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
     
     
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)
     
     
def lcm(m, n):
    return m * n // gcd(m,n)
     
     
def main():
    n = int(input())
    t = []
    for i in range(n):
        tmp = int(input())
        t.append(tmp)
    ans = t[0]
    for i in t:
        ans = lcm(ans, i)
    print(ans)
     
     
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
Ts = [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)
 
def solve(Ts):
    if len(Ts) == 1:
        print(Ts[0])
    
    else:
        Ts_temp = []
        for i in range(len(Ts)-1):
            Ts_temp.append(lcm(Ts[i], Ts[i+1]))
        solve(Ts_temp)
 
solve(Ts)

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())
Ts=[]
c=1
for i in range(N):
 c=lcm(c,int(input()))
print(int(c))

Submission status: Accepted

Solution code:
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x
    
def lcm(x, y):
    return x * y // gcd(x, y)
    
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
temp = T[0]
for i in range(N-1):
    temp = lcm(temp, T[i+1])
print(temp)

Submission status: Accepted

Solution code:
def gcd(x, y):
    y, x = sorted([x, y])
    while y > 0:
        t = y
        y = x % y
        x = t
    return x

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

lcm = 1
for i in range(n):
    lcm = lcm * t[i] // gcd(lcm, t[i])

print(lcm)

Submission status: Accepted

Solution code:
def gcd(a, b):
    """最大公約数(Greatest Common divisor)を求める.

    ユークリッドの互除法の実装.
    ああああ

    Parameters
    ----------
    a : int
        自然数.
    b : int
        自然数.

    Returns
    -------
    int
        最大公約数
    """
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    """最小公約数(least common multiple)を求める.

    Parameters
    ----------
    a : int
        自然数.
    b : int
        自然数.

    Returns
    -------
    int
        最小公倍数
    """
    return a * b // gcd(a, b)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
ans = 1
for t in T:
    ans = lcm(ans, t)
print(ans)

Submission status: Accepted

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

import fractions
def gcd(a, b):
    return fractions.gcd(a, b)

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

x = 1
for i in range(N):
    for j in range(N):
        x = lcm(x, lcm(T[i], T[j]))


if x <= 10 ** 18:
    print(x)
else:
    print(10 ** 18)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

lcm = 0
gcd = 0

for i in range(n):
    t = int(input())
    if(i == 0):
        lcm, gcd = t, t
        continue
    lcm = t
    r = gcd % t
    while(r!=0):
        lcm = r
        r = t % r
    gcd *= t
    gcd //= lcm
print(gcd)

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())
Ts = []
c = 1
for i in range(N):
    c = lcm(c, int(input()))
 
print(int(c))

Submission status: Accepted

Solution code:
import fractions

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

if n==1:
    print(a[0])
    exit()
elif n==2:
    g=fractions.gcd(a[0],a[1])
    print(a[0]*a[1]//g)
    exit()

else:
    g=fractions.gcd(a[0],a[1])
    lcm=a[0]*a[1]//g
    for i in range(2,n):
        g=fractions.gcd(lcm,a[i])
        lcm=a[i]*lcm//g

    print(lcm)

Submission status: Accepted

Solution code:
N = int(raw_input())

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

T = int(raw_input())
if N == 1:
    print T
else:
    f = T
    for i in xrange(1, N):
        T = int(raw_input())
        g = gcd(f, T)
        f = f / g * T
    print f

Submission status: Accepted

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

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

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


#a, bの最大公約数を求める
def gcd(a, b):
	r = max(a, b) % min(a, b)
	


	if (r == 0):
		return min(a, b)

	else:
		return gcd(r, min(a, b))


#a, bの最小公倍数を求める
def lcm(a, b):
	return a * b // gcd(a, b)



#リストTの全要素の最小公倍数を求める
def LCM(T):
	l = len(T)



	if(l == 1):
		return T[0]

	elif(l == 2):
		return lcm(T[0], T[1])



	T1, T2 = [], []

	for i in range(l // 2):
		T1.append(T[i])

	for j in range(l - l // 2):
		T2.append(T[j + l // 2])



	return lcm(LCM(T1), LCM(T2))



print(LCM(T))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**1
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = [I() for _ in range(n)]
    t = a[0]
    for c in a[1:]:
        t = t * c // fractions.gcd(t,c)

    return t



print(main())

Submission status: Accepted

Solution code:
cl = [int(input()) for i in range(int(input()))]
ans = 1

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

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

for i in cl:
    ans = lcm(ans,i)

print(ans)

Submission status: Accepted

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

#def gcd(m, n):
#    r = m % n
#    return gcd(n, r) if r else n

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

N = int(input())
Ts = []
c = 1
for i in range(N):
    c = lcm(c, int(input()))

print(int(c))

Submission status: Accepted

Solution code:
from functools import reduce

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

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

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

N = int(input())
Ts = []
c = 1
for i in range(N):
    c = lcm(c, int(input()))

print(int(c))

Submission status: Accepted

Solution code:
#ABC070C

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(raw_input())
res=1
for i in xrange(n):
 temp=int(raw_input())
 res=lcm(res,temp)
print res

Submission status: Accepted

Solution code:
N=int(input())
arr=[]
for a in range(N):
    a=int(input())
    if a in arr:
        continue
    arr.append(a)

def gcf(a,b):
    if b==0:return a
    return gcf(b,a%b)
def lcm(a,b):
    return a*b//gcf(a,b)

temp=1
for i in range(len(arr)):
    temp=lcm(temp,arr[i])
print(temp)

Submission status: Accepted

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

def lcm(a,b):
    return  a*b//gcd(a,b)
    
n=int(input())
t=[int(input()) for i in range(n)]

anser=1
for i in t:
    anser=lcm(anser,i)
print(anser)

Submission status: Accepted

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

total = int(input())
param_list = [int(input()) for i in range(total)]

result = param_list[0]
for i in range(1, total):
    result = lcm(result, param_list[i])

print(result)

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)
a=1
for _ in range(int(input())):
    a=lcm(a,int(input()))
print(a)

Submission status: Accepted

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

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


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


for i in range(0, N):
    num = int(input())
    result = lcm(result, num)
print(int(result))

Submission status: Accepted

Solution code:
#from math import * 
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)

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

Submission status: Accepted

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

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

N = int(input())

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

print(result)

Submission status: Accepted

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

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

N = input()
V = 1
for i in range(int(N)):
    T = input()
    V = lcm(V, int(T))

print(V)

Submission status: Accepted

Solution code:
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result//uq(result,f)))*f
    
print((int)(result))

Submission status: Accepted

Solution code:
from fractions import gcd

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
# 最小公倍数が欲しい
ans = 1
for i in T:
    ans = int(ans * i //gcd(ans, i))
print(ans)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

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


n = int(input())
a = list(map(int, [input() for _ in range(n)]))
print(reduce(lcm, a))

Submission status: Accepted

Solution code:
def lcm(a, b):
    ax = a
    bx = b
    if a<b:
        ax, bx = (bx, ax)
    while True:
        if ax%bx == 0:
            gcd = bx
            break
        else:
            c = bx
            bx = ax%bx
            ax = c
    return a*b // gcd

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

while True:    
    if n==1:
        print(lst[0])
        break
    lst2.append(lcm(lst[0], lst[1]))
    lst.pop(0)
    lst.pop(0)
    lst2.extend(lst)
    if len(lst2)==1:
        print(lst2[0])
        break
    lst.clear()
        
    lst.append(lcm(lst2[0], lst2[1]))
    lst2.pop(0)
    lst2.pop(0)
    lst.extend(lst2)
    if len(lst)==1:
        print(lst[0])
        break
    lst2.clear()

Submission status: Accepted

Solution code:
import functools

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)

n = int(input())
print(functools.reduce(lcm, [int(input()) for i in range(n)]))

Submission status: Accepted

Solution code:
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)

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

Submission status: Accepted

Solution code:
from fractions import gcd

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

n, ts = int (input ()), []
for i in range (n):
    ts.append (int (input ()))

ans = 1
for i in range (n):
    ans = lcm (ans, ts[i])

print (ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input().strip())
    res = int(input().strip())
    if N == 1:
        print(res)
        return
    for _ in range(1, N):
        t = int(input().strip())
        res = lcm(res, t)
    print(res)


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


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def func(a,b):
    return a if b==0 else func(b,a%b)
n = int(input())
num = int(input())
for i in range(n-1):
    d = int(input())
    num = num*d//func(num,d)
print(num)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
print(reduce(lcm, T))

Submission status: Accepted

Solution code:
import fractions

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

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

ans = 1
for t in T:
    ans = lcm(ans, t)
print 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())
T = [int(input()) for i in range(N)]

T.sort(reverse=True)
ans = 1
for i in T:
    ans = lcm(ans, i)
print(ans)

Submission status: Accepted

Solution code:
import math as m
from functools import reduce
n,T= int(input()),[]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range(n):
    T.append(int(input()))
tmp = max(T)
for i in range(n):
    if tmp % T[i] != 0:
        tmp = T[i]//gcd(tmp, T[i])*tmp

print(tmp)

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


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


def ppcm(a, b):
    return (a * b) // pgcd(a, b)


def main():
    n = read_int()
    t = [read_int() for i in range(n)]
    res = 1
    for i in t:
        res = ppcm(res, i)
    print(res)


main()

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

tmp = T[0]
for i in range(1, N):
    tmp = T[i]//gcd(tmp, T[i])*tmp
    
print(int(tmp))

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

tmp = max(T)
for i in range(N):
    if tmp % T[i] != 0:
        tmp = T[i]//gcd(tmp, T[i])*tmp

print(int(tmp))

Submission status: Accepted

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

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

if max(T) > 5*10**17:
    print(max(T))
    
else:
    tmp = max(T)
    for i in range(N):
        if tmp % T[i] != 0:
            tmp = T[i]//gcd(tmp, T[i])*tmp

    print(int(tmp))

Submission status: Accepted

Solution code:
# your code goes here
def gcd(a,b):
    if b>a:
        t=b
        b=a
        a=t
    a1=a
    b1=b
    while b1>0:
        r=a1%b1
        a1=b1
        b1=r
    a//=a1
    a*=b
    return a
N=int(input())
T=[int(input()) for i in range(N)]
if N==1:
    print (T[0])
else:
    m=gcd(T[0],T[1])
    i=2
    while i <N:
        m=gcd(m,T[i])
        i+=1
    print(m)

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input()) 
t = sorted([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)
	
def nlcm(list):
  if len(list) > 2:
    lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(list[-1])

nlcm(t)

Submission status: Accepted

Solution code:
#! -*- coding:utf-8 -*-
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())
k = []
for i in range(n):
    k.append(int(input()))

if n == 1:
    print(k[0])
else:
    p = lcm(k[0],k[1])
    for i in range(n):
        p = lcm(p,k[i])
    print(int(p))

Submission status: Accepted

Solution code:
#Multiple Clocks
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    

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

a = T[0]

for Ti in T[1:]:
    a = lcm(a, Ti)

print(a)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    T = tuple(int(input()) for _ in range(N))

    lcm_ = T[0]
    for i in T:
        lcm_ = lcm(i, lcm_)

    print(lcm_)

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

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

main()

Submission status: Accepted

Solution code:
from functools import reduce
n  = int(input())
data = [int(input()) for x in range(n)]




def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

def lcmm(*args):
    """Return lcm of args."""   
    return reduce(lcm, args)

print(lcmm(*data))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

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

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

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    T = []
    for i in range(N):
        input_raw = read_func().strip().split()
        T.append(int(input_raw[0]))

    T.sort()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def Q3(x):
    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)

    N = x[0]
    lst = x[1:]
    if N == 1:
        return lst[0]
    else:
        l = lcm(lst[0], lst[1])
        for x in lst:
            l = lcm(l, x)
        return l

n = int(input())
t = [int(input()) for i in range(n)]
t.insert(0,n)
print(Q3(t))

Submission status: Accepted

Solution code:

def gcd(a, b):
    if a < b:
        c = a
        a = b
        b = c

    r = a % b

    while r > 0:
        a = b
        b = r
        r = a % b

    return b

    # ll gcd(ll a, ll b) {
    #   if (a < b)
    #     swap(a, b);
    #   ll r = a % b;
    #
    #   while (r) {
    #     a = b;
    #     b = r;
    #     r = a % b;
    #   }
    #
    #   return b;
    # }


N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
# a = list(map(int, input().split()))

ans = a[0]

for i in range(N):
    if i == 0:
        continue

    g = gcd(ans, a[i])
    ans = ans * a[i] // g

print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3


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

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = T[-1]
for i in T[:-1]:
    a = (a * i) // gcd(a, i)

print(a)

Submission status: Accepted

Solution code:
from fractions import gcd
 
def lcm(a, b):
    return a * b // gcd (a, b)

def nlcm(nums):
    d = 1
    for num in nums:
        d = lcm(d,num)
    return d
 
if __name__ == '__main__':
    N = int(input())
    nums = []
    for i in range(N):
        nums.append(int(input()))
 
    print(nlcm(nums))