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:
from functools import reduce

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

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

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

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

Submission status: Accepted

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

from functools import reduce

# GCD and LCM are not in math module.  They are in gmpy, but these are simple enough:

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b // gcd(a, b)

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

print(reduce(lcm, ts))
# ans = 1
# for i in range(N):
#   ans = lcm(ans, ts[i])
# print(ans)

Submission status: Accepted

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

from functools import reduce
import math

# GCD and LCM are not in math module.  They are in gmpy, but these are simple enough:

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b // gcd(a, b)

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

# print(reduce(lcm, ts))
ans = 1
for i in range(N):
  ans = lcm(ans, ts[i])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem C


# See:
# https://note.nkmk.me/python-gcd-lcm/
# https://docs.python.jp/3/library/functools.html
# https://docs.python.jp/3/library/fractions.html
def lcm_for_list(numbers):
    from functools import reduce
    return reduce(lcm, numbers, 1)


def lcm(x, y):
    from fractions import gcd  # for Ver.3.4 or lower.
    return (x * y) // gcd(x, y)


if __name__ == '__main__':
    n = int(input())
    t = [int(input()) for _ in range(n)]
    print(lcm_for_list(t))

Submission status: Accepted

Solution code:
def lcm(a, b):
    c = max(a, b)
    d = min(a, b)
    while d != 0:
        r = c % d
        c, d = d, r

    return a * b // c


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

if len(t) == 1:
    ans = t[0]
else:
    ans = lcm(t[0], t[1])
    for i in range(2, len(t)):
        ans = lcm(t[i], ans)


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

N = int(input())

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

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

print(ans)

Submission status: Accepted

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

n = int(input())

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

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

ans = 1
for _ in range(n):
    t = int(input())
    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())
res = 1
for i in range(n):
    t = int(input())
    res = lcm(res, t)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

for i in tt:
    p = []
    p.append(int(ss))
    p.append(int(i))
    q = list(sorted(p))
    while q[1] % q[0] != 0:
        r = [q[1] % q[0] , q[0]]
        s = list(sorted(r))
        q[0] = int(s[0])
        q[1] = int(s[1])

        
    ss = int(ss * i) // q[0]

print(ss)

Submission status: Accepted

Solution code:
def f(a,b):
    x,y=a,b
    while b>0:
        a,b=b,a%b
    return (x//a)*y
s=1    
N=int(input())
for i in range(N):
    a=s
    b=int(input())
    s=f(a,b)
print(s)

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

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

print(Ans)

Submission status: Accepted

Solution code:
def c_multiple_clocks(N, 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)

    ans = 1
    for x in T:
        ans = lcm(ans, x)
    return ans

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

Submission status: Accepted

Solution code:
import functools

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_base(x, y):
    return (x * y) // gcd(x, y)

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

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



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

Submission status: Accepted

Solution code:
import sys
if sys.version_info < (3, 5):
    from fractions import gcd
else:
    from math import gcd

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

def solve():
    n = int(input())
    tl = [int(input()) for _ in range(n)]
    ans = tl[0]
    for elem in tl[1:]:
        ans = lcm(ans, elem)
    print(ans)
 
if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
from fractions import gcd

def lcm(a, b):
    if a == 0 or b == 0:
        return 0
    return int(a * b // gcd(a, b))
  
def solve():
    n = int(input())
    tl = [int(input()) for _ in range(n)]
    ans = tl[0]
    for elem in tl[1:]:
        ans = lcm(ans, elem)
    print(ans)
 
if __name__=="__main__":
    solve()

Submission status: Accepted

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

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

def lcm(x, y):
    g = gcd(x, y)
    # / で割ると小数判定になり、答えがイカれる。
    return x // g * y

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

print(ans)

Submission status: Accepted

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

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

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)


if __name__ == '__main__':
    t = [int(input()) for _ in range(int(input()))]
    print(reduce(lambda x, y: lcm(x, y), t))

Submission status: Accepted

Solution code:
def c_multiple_Clocks(N, 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)

    ans = 1
    for x in T:
        ans = lcm(ans, x)
    return ans

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

Submission status: Accepted

Solution code:
import fractions

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
N = int(input())
ans = 1
for _ in range(N):
    T = int(input())
    ans = ans*T // int(gcd(ans,T))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
t=1
for i in range(n):
    s=int(input())
    if t>s: a,b=t,s
    else: a,b=s,t
    
    while b!=0:
        a, b = b, a%b
    t=t*s//a
print(t)

Submission status: Accepted

Solution code:
import functools
import math

def gcd(x,y):
    a,b = max(x,y), min(x,y)
    while b != 0:
        a,b = b,a%b

    return a

def lcm2(x,y):
    return x*y // gcd(x,y)
    
N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

result = 1
for t in T:
    result = lcm2(result, t)

print(result)

Submission status: Accepted

Solution code:
n=int(input())
def Euclid(a,b):
    if a<b:
        return Euclid(b,a)
    if a%b==0:
        return b
    return Euclid(b,a%b)

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

N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
result = 1

for i in range(n):
  tmp = int(input())
  result = result*tmp//GoJoHo(result,tmp)
print(result)

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

tmp = int(input())
res = 0
if n == 1:
    print(tmp)
else:
    for i in range(n-1):
        tmp2 = int(input())
        res = lcm(tmp, tmp2)
        tmp = res
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc_gcd (a, b) :
    p = a * b

    if a > b:
        a, b = b, a

    while b != 0:
        a, b = b, a % b

    return p // a


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

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

while len(T) > 1:
    T = [calc_gcd(T[0], T[1])] + T[2:]

print(T[0])

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

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=1
for i in t:
    ans=lcm(ans,i)
print(int(ans))

Submission status: Accepted

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

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

n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = lcd(ans, i)
print(int(ans))

Submission status: Accepted

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

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

n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = lcd(ans, i)
print(int(ans))

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache
sys.setrecursionlimit(10000)



n=int(input())

@lru_cache(maxsize=1000)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
def lcm(a, b):
	return a * b // gcd (a, b)

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

print(x)

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)
    
l = 1
for i in t:
    l = lcm(l,i)

print(l)

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

print(S)

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(input())
if n==1:
    print(int(input()))
    exit()
ans=1
for i in range(n):
    ans=lcm(ans,int(input()))
print(int(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 a*b//gcd(a,b)
n=int(input())
if n==1:
    print(int(input()))
    exit()
ans=1
for i in range(n):
    ans=lcm(ans,int(input()))
print(int(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 = list(int(input()) for i in range(n))
mxt = max(t)
ls = []
ans = 0
j = 0
mod_flag = False

for i in range(n):
    if not mxt == t[i] and not mxt % t[i] == 0:
        mod_flag = True
        ls.append(t[i])
        j+=1
    
if not mod_flag:
    ans = mxt

if ans == 0:
    ans += mxt
    for i in range(len(ls)):
        if not ans % ls[i] == 0:
            ans = lcm(ans,ls[i])
    
print(ans)

Submission status: Accepted

Solution code:
def koubai(a,b):
    if b==0:
        return a
    return(koubai(b,a%b))
def kouyaku(a,b):
    return a*b//koubai(a,b)

N=int(input())
if N==1:
    print(int(input()))
    exit()
ans=1
for i in range(N):
    ans=kouyaku(ans,int(input()))
print(int(ans))

Submission status: Accepted

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

def euclid_gcd(a, b):
    assert(a >= b)
    while b != 0:
        _, m = divmod(a, b)
        a, b = b, m
    return a


def lcm(a, b):
    if b > a:
        a, b = b, a
    assert(a >= b)
    gcd = euclid_gcd(a, b)
    return a*b//gcd

print(reduce(lcm, xs))

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(input())

res = 1

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

print(res)

Submission status: Accepted

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

def lcm(a, b):
    return a * b // 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
import collections
import math
import fractions

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

def main():
	count = int(input())
	i = 0
	tmp = 1
	while(i < count):
		i += 1
		num = int(input())
		tmp = lcm(tmp,num)
	print(int(tmp))
if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import collections
import math
import fractions 

# code start
raw_input = input


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

def main():
	count = int(input())
	i = 0
	temp = 1
	while(i<count):
		i+=1
		num = int(input())
		temp = lcm(temp,num)
	print(int(temp))


if __name__ == '__main__':
    main()

# code end

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(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

def main():
  n = int(input())
  li = []
  for i in range(n):
    inp = int(input())
    li.append(inp)

  ans = int(reduce((lambda x, y: lcm(x, y)), li))
  if ans > 1000000000000000000:
    ans = 1000000000000000000
  print(ans)

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
import fractions

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


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

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

print ans

Submission status: Accepted

Solution code:
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

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

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

Submission status: Accepted

Solution code:
from fractions import gcd

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
def lcm(a, b):
    g = gcd(a, b)
    return a * b // g

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

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(x,y):
	if x < y:
		x,y = y,x
	while y > 0:
		r = x % y
		x = y
		y = r
	return x

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

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

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

print(int(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)


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

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_list = []
result = 1
for t in range(n):
    result = lcm(result,int(input()))
print(result)

Submission status: Accepted

Solution code:
# list: ソート済配列
# n: 参照番号
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)]
ans = 1

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
def gcd(m, n):
    while n:
	    m, n = (n, m % n)
    return m
def lcm(m, n):
    return m * n // gcd (m, n)

p = a[0] 

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

print(p)

Submission status: Accepted

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


n = int(input())
lcm = 1
for i in range(n):
    t = int(input())
    lcm = lcm*t // greatest_common_divisor(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)

ans=1
n=int(input())
t=[0 for i in range(n)]
for i in range(n):
    t[i]=int(input())

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

#print(lcm(t[0],t[1]))
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
A = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

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

n=input()<<A>>int
ret = 1
for i in range(n): a=int(input()); ret = ret * a // gcd(ret, a)
print(ret);

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for _ 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)

l = 1

for i in T:
    l = lcm(l, i)

print(l)

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

print reduce(lcm, T)

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:
from sys import stdin, stdout
def readAll_int(): return list(map(int, stdin))

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 = list(set(readAll_int()))
    if len(t)>1:
        for i in range(len(t) - 1):
            a = lcm(t[i], t[i+1])
            t[i+1] = a
    else:
        a = t[0]
    print(a)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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)

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

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(input())

ret = 1

for _ in range(N):
    ret = lcm(ret, int(input()))

print(ret)

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a < b: b, a = 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())

ret = 1

for _ in range(N):
    ret = lcm(ret, int(input()))

print(ret)

Submission status: Accepted

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

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

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

times = [int(raw_input()) for i in xrange(int(raw_input()))]
print lcm_multiple(*times)

Submission status: Accepted

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

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

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

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/gcd(x, y)*y


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

Submission status: Accepted

Solution code:
N = int(input())
T= [0]*N
for i in range(N):
    T[i] = int(input())
T.sort(reverse=True)
def gcd(n,m):
    while m > 0:
        n , m = m , n%m
    return n
def lcm(n,m):
     x = n*m//gcd(n,m)
     return x
for i in range(N-1):
    T[i+1] = lcm(T[i],T[i+1])
print(T[N-1])

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)]
for i in range(n-1):
    t[i+1] = lcm(t[i],t[i+1])
print(t[n-1])

Submission status: Accepted

Solution code:
def euclid(a,b):
	if b == 0:
		return a
	else:
		return euclid(b,a % b)
		
n = int(input())
t = []
for i in range(n):
	x = int(input())
	t.append(x)

for i in range(0,n-1):
	t[i+1] = t[i] * t[i+1] // euclid(t[i],t[i+1])

print(int(t[n-1]))

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def main():
    N = int(input())
    t_list = list(sorted([int(input()) for _ in range(N)]))
    ans = 1
    for t in t_list:
        ans = lcm(ans, t)

    print(ans)

if __name__ == '__main__':
    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
    
def lcm(a, b):
	return a * b // gcd (a, b)
if N == 1:
    print(T[0])
else:
    result = lcm(T[0],T[1])

    for x in range(2,N):
        result = lcm(result, T[x])

    print(result)

Submission status: Accepted

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

def lcm(a,b):
    return a*b//gcd(a,b)
T=[]
N=int(input())
for i in range(N):
    T.append(int(input()))

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

print(int(ans))

Submission status: Accepted

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

N = input()
T = [input() for i in range(N)]
ans = 1
for i in range(N):
    v = gcd(max(ans, T[i]), min(ans, T[i]))
    ans = ans * (T[i] / v)
print ans

Submission status: Accepted

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

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


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


def solve(clocks):
    temp_lcm = clocks[0]
    for n in clocks[1:]:
        temp_lcm = lcm(temp_lcm, n)
    return temp_lcm


def main():
    N = int(input())
    clocks = [int(input()) for _ in range(N)]
    result = solve(clocks)
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())
t = [int(input()) for i in range(N)]
for i in range(N-1):
    t[i+1] = t[i]*t[i+1]//yuclid(t[i], t[i+1])

print(t[N - 1])

Submission status: Accepted

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

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

print(t[n - 1])

Submission status: Accepted

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

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


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

print(t[n - 1])

Submission status: Accepted

Solution code:
def GCD(a, b):
    if a > b:
        A = a
        B = b
    elif b > a:
        A = b
        B = a
    else:
        return a

    r = A % B
    while r != 0:
        A = B
        B = r
        r = A % B

    return B


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


def solve(): # ABC070C- Multiple Clocks
    while 1:
        try:
            n = int(input())
            T = []
            for _ in range(n):
                T.append(int(input()))

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

            print(l)
        except:
            break
            
            
solve()

Submission status: Accepted

Solution code:
import sys

def scp(a, b):
    if b > a:
        tmp_a = a
        a = b
        b = tmp_a
    while b:
        r = a % b
        a = b
        b = r
    return a
    #for i in xrange(100000, 2, -1):
    #    if a % i == b % i == 0:
    #        return a * b / i
    #return a * b

N = int(raw_input())
array = []
for i in range(N):
    array.append(int(raw_input()))

array.sort()

#if array[-1] > pow(10, 9):
#    print array[-1]
#    sys.exit(0)

result = array[0]
for i in array[1:]:
    result = result / scp(result, i) * i
print result

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

n = int(input())
clocks = []
for i in range(n):
    clocks.append(int(input()))
print(reduce(lambda x, y: (x * y) // gcd(x, y), clocks))

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

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

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd

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

res = 1
for t in T:
  res = res // gcd(res, t) * t
print(res)

Submission status: Accepted

Solution code:
N = int(input())
T = [int(input()) for n 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)


res = T[0]
for t in T:
    res = lcm(res, t)

print(res)