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:
def gcd(a, b):
    if a < b:
        a,b = b,a
    while b > 0:
        r = a % b
        a,b = b,r
    return a

def lcm(a, b):
    if a == 0 or b == 0:
        print("Error")
        return 0
    return int(a * b // gcd(a, b))

def arrlcm(a):
    alen = len(a)
    if alen == 3:
        return lcm(a[0], lcm(a[1], a[2]))
    elif alen == 2:
        return lcm(a[0], a[1])
    elif alen == 1:
        return a[0] # 最初から1つ
    elif alen == 0:
        return 0
    else:
        return lcm(arrlcm(a[:alen//2]), arrlcm(a[alen//2:]))

def solve():
    n = int(input())
    print(arrlcm([int(input()) for _ in range(n)]))


if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
def c():
    n = int(input())
    t = {int(input()) for _ in range(n)}
    # lowest common minimum
    from fractions import gcd
    from functools import reduce
    def lcm(a, b):
        return (a * b) // gcd(a, b)
    print( reduce(lcm, t) )

c()

Submission status: Accepted

Solution code:
N=int(input())
T=[]
for i in range(N):
    T.append(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)
if N==1:
    print(T[0])
elif N==2:
    print(lcm(T[0],T[1]))
else:
    l=[T[0]]
    for i in range(N-1):
      l.append(lcm(l[i],T[i+1]))
    print(l[-1])

Submission status: Accepted

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

r = 1
nbClock = int(input())
for i in range(nbClock):
   c = int(input())
   g = gcd(r,c)
   r = r * (c//g)
print(r)

Submission status: Accepted

Solution code:

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

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

S = set(T)
res = 1
for j in S:
    res = res * j // gcd(res, j)
    
print(int(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)


if __name__ == '__main__':
    N = int(input())
    T = []
    for i in range(N):
        T.append(int(input()))
    tmp = T[0]
    for j in range(N - 1):
        tmp = lcm(tmp, T[j+1])
    print(tmp)

Submission status: Accepted

Solution code:
N = int(input())
t = []
y = []
for i in range(N):
  t.append(int(input()))
t.append(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 j in range(N):
  t[j+1] = lcm(t[j],t[j+1])
  
print(t[N])

Submission status: Accepted

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

n = int(input())

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

print(ans)

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)

ans = 1
for i in t:
    ans = lcm(ans, i)

print(ans)

Submission status: Accepted

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

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 i in range(len(T)):
	ans=lcm(ans,T[i])
	#print "ans::"+str(ans)

print ans

Submission status: Accepted

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

n=int(input())
p=1
for i in range(n):
  m=int(input())
  p=p*m//gcd(p,m)
print(int(p))

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

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

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

print(ans)

Submission status: Accepted

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

t = []

for i in range(n):
    temp = raw_input()
    temp = int(temp)
    t.append(temp)

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

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

print x

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//gcd(a,b)*b

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

print(reduce(lcm,a))

Submission status: Accepted

Solution code:
import fractions
n = int(raw_input())
t = list()
for _ in range(n):
    t.append(int(raw_input()))
result = t[0]
for i in range(1, n):
    result = ((t[i] * result) / fractions.gcd(t[i], result))
print(result)

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())
res = int(input())
for i in range(1, n):
    x = int(input())
    res = LCM(res, x)
print(res)

Submission status: Accepted

Solution code:

n = int(input())
t = [ int(input()) for i in range(n)]
def gcd(a,b):
    if a<b:a,b = b,a 
    if b==0:return a
    else : return gcd(b,a%b)    

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

def lcm(b):
    ans = b[0]
    for i in b:
        ans = lc(ans,i)
    return ans
print(lcm(t))

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)

now = 0
time = int(input())
fi = 1
ans = 1
while now < time:
    thi = int(input())
    ans = lcm(ans, thi)
    now += 1
print(ans)

Submission status: Accepted

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

ret = 1
N = int(input())
for _ in range(N):
  T = int(input())
  p = pgcd(ret,T)
  ret *= (T//p)

print(ret)

Submission status: Accepted

Solution code:
def gcd(*numbers):
    """Return the greatest common divisor of the given integers"""
    from fractions import gcd
    return reduce(gcd, numbers)

# Least common multiple is not in standard libraries? It's in gmpy, but this is simple enough:

def lcm(*numbers):
    """Return lowest common multiple."""    
    def lcm(a, b):
        return (a * b) // gcd(a, b)
    return reduce(lcm, numbers, 1)
l = []
for x in range(int(raw_input())):
	l.append(int(raw_input()))
ans = 1
for x in l:
	ans = lcm(ans,x)
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:
from sys import stdin

def gcd(a, b):
  return a if b == 0 else gcd(b, a % b)
  
def lcm(a, b):
  return a * b // gcd(a,b)
  
N = int(input())
T = [int(t) for t in stdin]

answer = 1
for t in T:
  answer = lcm(answer, t)
  
print(answer)

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())
n_set = set([])

for i in range(n):
    tmp = int(input())
    n_set.add(tmp)

ans = 1
for i in range(len(list(n_set))):
    ans = lcm(ans, list(n_set)[i])

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())
ls = []
for i in range(n):
    ls.append(int(input()))
result = ls[0]
for i in ls[1:]:
    result = lcm(i,result)
print(result)

Submission status: Accepted

Solution code:
def yu(a, b):
	sa = a
	sb = b
	while(True):
		if a < b:
			tm = a
			a = b
			b = tm
		a = a % b
		if a == 0:
			return (sa*sb)/b


n = input()
t = []
for i in range(n):
	t.append(input())
for  i in range(n - 1):
	m = yu(t[i], t[i+1])
	t[i+1] = m
print(t[n-1])

Submission status: Accepted

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

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

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

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

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()))
res = functools.reduce(lcm, T)
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 = input()
T = [input() for i in range(N)]

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

print T[N-1]

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>0:
		a,b=b,a%b
	return a

n=int(input())
a=[0]*n
for i in range(n):
	a[i]=int(input())
if n==1:
	print(a[0])
else:
	r = a[0]*a[1]//gcd(a[0],a[1])
	for i in range(2,n):
		r = r * (a[i]//gcd(r,a[i]))
	print(int(r))

Submission status: Accepted

Solution code:
import sys

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())
if(N==1):
    print(int(input()))
    sys.exit()

T=[]
T.append(int(input()))

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

Submission status: Accepted

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

def lcm(a, b): 
    return abs(a * b) // gcd(a,b)
I = [int(input()) for n in range(N)]
print(int(reduce(lcm, I, 1)))

Submission status: Accepted

Solution code:
N = int(input())
 
a_list = []
for _ in range(N):
    a_list.append(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)
 
res = 1
for i in range(N):
    d = gcd(res, a_list[i])
    res = res // d
    res = res * a_list[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())
l = int(input())

i = 1

while i < n:
    l = lcm(l, int(input()))
    i = i + 1

print(l)

Submission status: Accepted

Solution code:
N = int(input())

def lcm(x, y):
    M = x * y
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return M // x
num = []
for _ in range(N):
    num.append(int(input()))
M = num[0]
for i in range(N):
    M = lcm(M, num[i])
print(M)

Submission status: Accepted

Solution code:
def gcd(m,n):
  if n == 0:
    return m
  else:
    r = m % n
    return gcd(n,r)
  
def LCM(num1,num2):
  return (num1/gcd(num2,num1))*num2

N = input()
l = []
for i in range(N):
  l.append(input())
l.sort()
lcm = l[N-1]
for i in range(N-1):
  lcm = LCM(l[N-2-i],lcm)
print lcm

Submission status: Accepted

Solution code:
n = int(input())
res = 1
def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x %y)
for i in range(n):
    x = int(input())
    res = res * x // gcd(res, x)
print(res)

Submission status: Accepted

Solution code:
def gcd(a,b):
	if b==0:
		return a
	return gcd(b,a%b)
n= int(raw_input())
a=[]
g=0
h=1
for i in range(n):
	x=int(raw_input())
	a.append(x)
h=a[0]
for i in a:
	
	h=(h*i)/gcd(h,i)
print h

Submission status: Accepted

Solution code:
from fractions import gcd
n = int(input())
x = 1

for i in range(n):
  t = int(input())
  g = gcd(t,x)
  t //= g
  x *= t

print(x)

Submission status: Accepted

Solution code:
N = input();

from fractions import gcd

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

print ans

Submission status: Accepted

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

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = (ret * hoge)//gcd(ret, hoge)
print(ret)

Submission status: Accepted

Solution code:

from functools import reduce


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

    return a


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


def main():
    n = int(input())

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

    print(reduce(lcm, ts))


if __name__ == "__main__":
    main()

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:
#from math import gcd
from fractions import gcd

n=int(input())

res=1
for _ in range(n):
    x=int(input())
    res=res//gcd(res,x)*x
print(res)

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/local/bin/python3.5 -tt

import fractions
import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield int(i)

    g = _(sys.stdin)

    N = next(g)

    lcm = 1

    for i in range(N):
        T = next(g)

        lcm = lcm * T // fractions.gcd(lcm, T)

    print(lcm)

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())						# 5

a = int(input())
for _ in range(N-1):
	a = lcm(a, int(input()))


print(a)

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=[]
for i in range(n):
 t.append(int(input()))
c=t[0]
for i in range(1,n):
 c=lcm(c,t[i])
print(c)

Submission status: Accepted

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(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)


def read():
    N = II()
    T = [II() for __ in range(N)]
    return N, T


def solve(N, T):
    ans = T[0]
    for i in range(1, N):
        ans = lcm(ans, T[i])
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

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)
n=int(raw_input())
ans=-1
while n>0:
    n-=1
    if ans==-1:
        ans=int(raw_input())
    else:
        x=int(raw_input())
        ans=lcm(ans,x)
print ans

Submission status: Accepted

Solution code:
from fractions import gcd
n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))
result = a[0]
for i in range(1, n):
    result = result * a[i] / gcd(result, a[i])
print result

Submission status: Accepted

Solution code:

def ggt(a, b):
    if b == 0:
        return a

    return ggt(b, a % b)

N = int(input())

erg = int(input())

for i in range(N-1):
    t = int(input())

    g = ggt(erg, t)
    erg = (erg // g) * t

print(erg)

Submission status: Accepted

Solution code:
import fractions

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

ans = 1

for i in T:
    ans = ans / fractions.gcd(ans, i) * i

print ans

Submission status: Accepted

Solution code:
import fractions

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

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

Submission status: Accepted

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

s = int(input())
for i in range(N - 1):
    tmp = int(input())
    s = lcm(s, tmp)

print(s)

Submission status: Accepted

Solution code:
def __gcd(x,y):
    while(y!=0):
        x,y=y,x%y
    return x

def __lcm(x,y):
    g = __gcd(x,y)
    return (x//g)*y


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

#print(L)
a = L[0]
for i in range(1,n):
    a = __lcm(a,L[i])

print(a)

Submission status: Accepted

Solution code:
n=int(raw_input())
def gcd(a,b):
  if b==0 :
    return a
  return gcd(b,a%b)
y=1
for i in range(n) :
  x=int(raw_input())
  z=gcd(x,y)
  y=x*y/z
print y

Submission status: Accepted

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

n = int(input())
x = int(input())
for _ in range(n-1):
    i = int(input())
    x = (x * i) // gcd(x,i)

print(x)

Submission status: Accepted

Solution code:
n = int(input().strip())
ts = []
for _ in range(n):
    ts.append(int(input().strip()))

def gcd(m, n):
    while 1:
        mod = m % n
        if mod == 0:
            return n
        m, n = n, mod

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

from functools import reduce

print(reduce(lcm, ts))

Submission status: Accepted

Solution code:
from fractions import gcd


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


n = int(input())
ts = {int(input()) for _ in range(n)}
a = ts.pop()
for b in ts:
    a = lcm(a, b)
print(a)

Submission status: Accepted

Solution code:
N = 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)
  
tmp = 1
for n in range(N):
    tmp = lcm(tmp,int(input()))
print(tmp)

Submission status: Accepted

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

def getlcm(a,b):
    return (a*b)/gcd(a,b)
    
n=int(raw_input(''))
x=int(raw_input(''))
lcm=x

for i in range(1,n,1):
    x=int(raw_input(''))
    lcm=getlcm(lcm,x)
print lcm

Submission status: Accepted

Solution code:
# encoding:utf-8
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 main():
	n = int(input())
	nums = [int(input()) for _ in range(n)]

	out = reduce(lcm, nums)
	print(out)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

import fractions


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

N = ri()
t = ri()
for i in range(N-1):
  t = lcm(t, ri())
print(t)

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(a, b):
    return a * b // gcd (a, b)
def f():
    n = int(input())
    a=[]
    l=1
    for i in range(n):
        s=(int(input()))
        l=lcm(l,s)
    print(l)
f()

Submission status: Accepted

Solution code:
def HCF(a,b):
    if a==0:
        return b
    return HCF(b%a,a)
N = long(raw_input())
x = long(raw_input())
for i in range(1,N):
    y = long(raw_input())
    x = (x*y)/HCF(x,y)
print x

Submission status: Accepted

Solution code:
n=input()

a=[0 for i in range(n)]
def gcd(num1,num2):
    if num2 == 0:
        return num1
    else:
        return gcd(num2,num1%num2)

def lcm(num1,num2):
    tmp = gcd(num1,num2)
    return num1*num2/tmp

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

Submission status: Accepted

Solution code:
n = int(raw_input())

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

r = 1

for i in xrange(n):
    t = int(raw_input())
    cd = gcd(r, t)
    m = t // cd
    r *= m

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)

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

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

n = int(raw_input())
t = [int(raw_input()) for _ in xrange(n)]
ans = 1
for i in xrange(n):
    ans = lcm(ans, t[i])
print ans

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

ans = 1
for i in xrange(N):
    ans = lcm(ans, T[i])

print ans

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

n = ni()
g = 0
for i in range(n):
    v = ni()
    if g == 0:
        g = v
    else:
        g = g//gcd(g,v)*v
print(g)

Submission status: Accepted

Solution code:
def gcd(x,y):
    if y==0:
        return x
    return gcd(y, x % y)
g = 1
for i in xrange(int(raw_input())):
    w = int(raw_input())
    g = g * w / gcd(g, w)
print g

Submission status: Accepted

Solution code:
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def lcm(m, n):
    return m*n//gcd(m, n)
n = int(input())
ans = 1
for i in range(n):
    ans = lcm(ans, int(input()))
print("%d" % ans)

Submission status: Accepted

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

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
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(lis))

Submission status: Runtime Error

Solution code:
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm(lis))

Submission status: Runtime Error

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

print(lcm(lis))

Submission status: Runtime Error

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 / g * b

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1
for i in range(len(T)):
    ans = lcm(ans, T[i])

print(int(ans))

Submission status: Runtime Error

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

print(int(ans))

Submission status: Runtime Error

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

print(int(ans))

Submission status: Runtime Error

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

for i in range(1, N):
    ans = int((ans * T[i]) / math.gcd(ans, T[i]))

print(ans)

Submission status: Runtime Error

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

for i in range(N):
    ans = int((ans * T[i]) / math.gcd(ans, T[i]))

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = int(T / gcd(T, t) * t)
print(int(T))

Submission status: Runtime Error

Solution code:
from math import gcd
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = int(T * t / gcd(T, t))
print(int(T))

Submission status: Runtime Error

Solution code:
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
N = int(input())
T = []
ans = 1
for i in range(N):
    T.append(int(input()))

for i in range(N):
    ans = (ans * T[i]) / gcd(ans, T[i]) 

print(int(ans))

Submission status: Runtime Error

Solution code:
import math


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


def main():
    n = int(input())
    t_lst = [int(input()) for _ in range(n)]
    t_lst.sort()
    answer = t_lst[0]
    for i in range(1, n):
        t = t_lst[i]
        answer = lcm(answer, t)
        answer = int(answer)

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


def main():
  n = int(input())
  l = []
  for i in range(n):
    a = int(input())
    l.append(a)
  ans = 1
  for i in range(len(l)):
    ans = l[i] / gcd(l[i], ans) * ans
  print(int(ans))
    
  return 0


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
from math import *

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

N=int(input())
T=[int(input()) for _ in range(N)]
a=T[0]
for i in range(1,N):
  ans=lcm(a,T[i])
  a=ans
print(ans)

Submission status: Runtime Error

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    t = i_input()
    for i in range(n-1):
        k = i_input()
        t = t*k/gcd(t,k)
        t = int(t)
    print(t)



if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
n= int(input())
a=int(input())
b=int(input())
import math

c=(a*b)//math.gcd(a,b)
for i in range(n-2):
	b=int(input())
	c=(c*b)//math.gcd(c,b)

print(c)

Submission status: Runtime Error

Solution code:
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	carry = 0
	for j in range(len(b)):
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def gcd(a, b):
	if bigint_compare(a, b) >= 0:
		M = a
		m = b
	else:
		M = b
		m = a
	if m == "0":
		return M
	else:
		q = bigint_divide(M, m)
		r = bigint_minus(M, bigint_multiply(m, q))
		return gcd(m, r)

def lcm(a, b):
	return bigint_divide(bigint_multiply(a, b), gcd(a, b))

def main():
	N = int(input())
	T = [input() for i in range(N)]
	ans = 1
	for i in range(len(T)):
		ans = lcm(T[i], ans)

	print(ans)

main()

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = []  
  for i in range(n):
    a.append(int(input()))
if n == 1:
  print(a[0])
else:
  lcm = (a[0] * a[1]) // math.gcd(a[0], a[1])
  for i in range(2, n):
    lcm = (lcm * a[i]) // math.gcd(lcm, a[i])
  print(lcm)