Problem:


Score : 300 points

Problem Statement

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

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

Now, Dolphin starts all the clocks simultaneously.

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

Constraints

1≤N≤100 

1≤T_i≤10^{18} 

All input values are integers.  

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

Input

Input is given from Standard Input in the following format:  

N
T_1
:  
T_N

Output

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

Sample Input 1

2
2
3

Sample Output 1

6

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

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

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

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

Sample Input 2

5
2
5
10
1000000000000000000
1000000000000000000

Sample Output 2

1000000000000000000



Sample input:
2
2
3


Sample output:
6

Submission status: Accepted

Solution code:
import numpy as np

# 2整数の最大公約数を求める関数を定義する
def get_gcd(a, b):
    a, b = max(a, b), min(a, b)
    c = a % b
    if c == 0:
        return b
    else:
        return get_gcd(b, c)

# --------------------------------------------

# 時計の数を入力する
N = int(input())
# 時計の周回時間を入力する
arr_T = np.empty(N, dtype = int)
for i in range(N):
    arr_T[i] = int(input())
# 周回時間を降順に並べる
arr_sort_T = np.sort(arr_T)[::-1]

# 全ての周回時間の最小公倍数を求める
# 最大周回時間を取り出す
max_T = np.max(arr_T)
m = max_T
if N != 1:
    # 繰り返し
    for n in arr_sort_T[1:]:
        gcd = get_gcd(m, n)
        m = (m // gcd) * n

# 結果を出力する
print(m)

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(a,b):
    return (a//gcd(a,b))*b
N,x=int(input()),1
for _ in range(N):
    x=lcm(x,int(input()))
print(x)

Submission status: Accepted

Solution code:
# ABC070-C
import fractions
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y ) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
print(lcm_list(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)

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

    print(t)

main()

Submission status: Accepted

Solution code:
import fractions
def lcm(x,y):return (x*y)//fractions.gcd(x,y)
pg = 1
for i in range(int(input())):pg=lcm(pg,int(input()))
print(pg)

Submission status: Accepted

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

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

N = int(input())
T_li = sorted([int(input()) for i in range(N)])
crr_lcm = T_li[0]

for i in range(1, N):
    crr_lcm = lcm(crr_lcm, T_li[i])
print(crr_lcm)

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
print(lcm(*IR(N)))

Submission status: Accepted

Solution code:
from fractions import*
_,*t=map(int,open(0))
a=1
for t in t:a*=t//gcd(a,t)
print(a)

Submission status: Accepted

Solution code:
from fractions import*
_,*t=open(0)
a=1
for t in t:
  t=int(t)
  a*=t//gcd(a,t)
print(a)

Submission status: Accepted

Solution code:
import fractions


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


N = int(input())
clock = [0] * N
for j in range(N):
    clock[j] = int(input())
gcd = clock[0]

ans = clock[0]
for i in range(1, N):
    gcd = GCD(ans, clock[i])
    ans = ans//gcd
    ans = ans * clock[i]

print(int(ans))

Submission status: Accepted

Solution code:
import fractions

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

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

print(LCM[-1])

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 = []

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

Submission status: Accepted

Solution code:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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


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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
def gcd(a, b):
  if not b:
    return a
  else:
    return gcd(b, a % b)
def lcm(a, b):
  return a * b // gcd(a, b)
ans = 1
for _ in range(n):
  c = int(input())
  ans = lcm(ans, c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(a,b):return (a//gcd(a,b))*b
N,x=int(input()),1
for _ in range(N):x=lcm(x,int(input()))
print(x)

Submission status: Accepted

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


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


def main():
    N = int(input())
    T = []
    for _ in range(N):
        T.append(int(input()))
    t = T[0]
    for i in range(1, N):
        t = lcm(max(t, T[i]), min(t, T[i]))
    print(t)


main()

Submission status: Accepted

Solution code:
# まあ最小公倍数lcmでしょう lcmのアルゴリズムはしらんけどたしかgcdを求めてからなんかするやつ

n = int(input())
x = int(input())


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


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


for _ in range(n - 1):
    y = int(input())
    x = lcm(x, y)

print(x)

Submission status: Accepted

Solution code:
#import math
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
# output LCM(T1,T2... Tn)=LCM(Tn,LCM(Tn-1,LCM(...)))
def gcd(a,b): #Recusion!!
  if min(a,b) == 0:
    return max(a,b)
  else:
    return gcd(min(a,b),max(a,b)%min(a,b))
    
"""
  mi = min(a,b)
  ma = max(a,b)
  ans = 1
  '''for i in range(2,mi+1):
    if (mi%i)+(ma%i) == 0:
      mi /= i
      ma /= i
      ans *= i
      i -= 1'''
  while True:
    #print(ma,mi)
    if (ma % mi) == 0:
      ans = mi
      break
    else:
      mi = ma%mi
      ma = mi
      
  return ans"""


def lcm(a,b):
  #g = math.gcd(a,b)
  g = gcd(a,b)
  #print(g)
  return int(a*b//g)
ans = T[0]
for i in range(1,len(T)):
  ans = lcm(ans,T[i])
print(ans)

Submission status: Accepted

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


lcm_now = 1
for t in t_list:
    lcm_now = lcm(lcm_now, t)
print(lcm_now)

Submission status: Accepted

Solution code:

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

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
common = n()
for i in range(N-1):
    common = lcm(common, n())

print(common)

Submission status: Accepted

Solution code:
#最大公約数を求める
def gcd(a,b):
    #a>bとなるように入れ替え
    if a < b:
        tmp = a
        a = b
        b = tmp
    
    #ユークリッドの互除法
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    
    return b

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

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

#Tのリストの2数のlcmを求めて範囲を広げていく
tmp_lcm = 1 #現在の範囲までのlcm
for i in range(N):
    tmp_lcm = lcm(tmp_lcm,T[i])

print(tmp_lcm)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

Submission status: Accepted

Solution code:
# 2019/06/22
# AtCoder Beginner Contest 070 - C

import fractions

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

# Input
n = int(input())
alcm = 1

for i in range(n):
    wt = int(input())
    alcm = lcm_fgf(alcm, wt)

# Output
print(alcm)

Submission status: Accepted

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

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

def main():
    num = int(input())
    ans = int(input())

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
#!/usr/bin/env python3
from fractions import gcd
#from math import gcd
N=int(input())
T=[int(input()) for _ in range(N)]
def lcm(a, b):
    return a*b//gcd(a,b)
tmp = T[0]
for t in T[1:]:
    tmp = lcm(tmp, t)
print(tmp)

Submission status: Accepted

Solution code:
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#最小公倍数
def lcm(a,b):
    x = gcd(a,b)
    return a*b//x
"""
from fractions import gcd
def lcm(a,b): 
    return a*b//gcd(a,b)
"""
n = int(input())
t=[]
for i in range(n):
    t.append(int(input()))
ans = 1
for i in range(n):
    ans = lcm(ans,t[i])
print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

print(lcm_list(t))

Submission status: Accepted

Solution code:
import fractions as frac
n=int(input())
t=[int(input()) for _ in range(n)]
t=sorted(set(t))
t1=t[0]
if len(t)==1:
    print(t1)
    exit()
for i in range(1,len(t)):
    t2=t[i]
    g=frac.gcd(t1,t2)
    ans=t1*t2//g
    t1=ans
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd as g
def l(a,b):
  x=a*b//g(a,b)
  return x
n=int(input())
m=int(input())
for _ in range(n-1):
  t=int(input())
  m=l(m,t)
print(m)

Submission status: Accepted

Solution code:
import fractions

N = int(input())

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s =set()

for _ in range(n):
    s.add(int(input()))

ls = list(s)

from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

print(lcm_list(ls))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
time = []

for i in range(n):
    time.append(int(input()))

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

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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


T1 = int(input())
ans = T1
for i in range(N-1):
    T2 = int(input())
    ans = T1 * T2 //gcd(T1, T2)
    T1 = ans

print (ans)

# print (gcd(12, 8))

Submission status: Accepted

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


def solve(N: int, T: "List[int]"):
    def gcd(a, b):
        if b == 0:
            return a
        return gcd(b, a % b)
    ret = T[0]
    for t in T:
        g = gcd(ret, t)
        ret = ret * t // g

    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, T)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

N=int(input())
for i in range(N):
    if i==0:
        b=int(input())
    else:
        a=int(input())
        c=gcd(a,b)
        b=c*(a//c)*(b//c)

print(b)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

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

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

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

print(lcm(ns))

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

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

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

def lcmm(l):
  return reduce(lcm, l)

print(lcmm(arr))

Submission status: Accepted

Solution code:
N = int(input())
a_list = []
for i in range(N):
    a_list.append(int(input()))
    
def gcd(a, b):
    if b > a:
        a, b = b, a
    while b != 0:
        tmp = a % b
        a, b = b, tmp
    return a

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

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

Submission status: Accepted

Solution code:
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)


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(N-1,-1,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Submission status: Accepted

Solution code:
import itertools
import math
def gcd(a,b):
    r = a % b
    if r == 0:
        return b
    return gcd(b,r)

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

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

Submission status: Accepted

Solution code:
def gcd(x, y):
    if x<y:x,y=y,x
    while x % y != 0:
        x, y = y, x % y
    return y
n=int(input())
l=[int(input()) for i in range(n)]
ans=l[0]
for i in l[1:]:
    ans=ans*i//gcd(ans,i)
print(ans)

Submission status: Accepted

Solution code:
import fractions
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
import fractions

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def euc(x, y):
	if y == 0: return x
	return euc(y, x%y)
N = int(input())
clocks = []
for i in range(0, N):
	clocks.append(int(input()))
ans = clocks[0]
for i in range(1, N):
	ans = ans * clocks[i] // euc(ans, clocks[i])
print(ans)

Submission status: Accepted

Solution code:
import math

l = input().split()
N = int(l[0])
T = []

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

# print(N, T)

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

lcm = T[0]
for t in T:
    d = gcd(lcm, t)
    lcm = lcm * t // d

print(lcm)

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

    print(ans)


def inputList():
    a=list(map(int,input().split()))
    return a


def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

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__'):
    main()

Submission status: Accepted

Solution code:
import fractions

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

ans = l[0]

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

print(ans)

Submission status: Accepted

Solution code:
import fractions

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
if n>=2:
    ans=t[0]*t[1]//(fractions.gcd(t[0],t[1]))
    for i in range(2,n):
        ans=ans*t[i]//(fractions.gcd(ans,t[i]))
    print(ans)
else:
    print(t[0])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

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

t1=T[0]
for t2 in T[1:]:
	t1=t1*t2//gcd(t1,t2)  

print(t1)

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)

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

print(reduce(lcm, T))

Submission status: Accepted

Solution code:
# ABC070C - Multiple Clocks
import sys
from fractions import gcd
input = sys.stdin.readline

n = int(input())
arr = list(map(int, [input().rstrip() for _ in range(n)]))
ans = 1
for i in arr:
    ans = ans * i // gcd(ans, i)
print(ans)

Submission status: Accepted

Solution code:

import fractions as math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

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

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

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

print(lcm_list(T))

Submission status: Accepted

Solution code:
import fractions
n=int(input())
t=[int(input()) for _ in range(n)]
t=sorted(t)[::-1]
x=t.pop()
while(t):
     y=t.pop()
     x=x*y//fractions.gcd(x,y)
     if x>5*10**17:
          break
print(x)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import fractions
n = int(input())
t = [int(input()) for i in range(n)]
def lcm(x, y):
    return (x * y) //fractions.gcd(x, y)
l = t[0]
for x in range(n):
    l = lcm(l,t[x])
print(l)

Submission status: Accepted

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

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

n = int(input())

if n == 1:
	ans = int(input())
else:
	ans = lcd(int(input()),int(input()))

	for i in range(n-2):
		m = int(input())
		ans = lcd(ans,m)
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)

from functools import reduce

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

print(reduce(lcm,t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

_, *t = map(int, open(0).read().split())
print(reduce(lcm, t))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

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

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

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

def main():
    N = int(input())
    li = []
    for i in range(N):
        li.append(int(input()))
    
    print(lcm_list(li))

main()

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
result = 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 _ in range(n):
    num = int(input())
    result = lcm(num, result)
print(result)

Submission status: Accepted

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

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

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

print(l)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N = int(input())
T = [int(input()) for _ in range(N)]

ans = lcm_list(T)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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


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


n = int(input())
print(lcm(*tuple(int(input()) for i in range(n))))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from fractions import gcd


n = int(input())
li_t = list()

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

# a * b = 最小公倍数 * 最大公約数


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

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

Submission status: Accepted

Solution code:
N = int(input())
T = []

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

a = 1

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

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

print(a)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
N = int(input())
T = [int(input()) for _ in range(N)]


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


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


print(lcm_list(T))

Submission status: Accepted

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


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


print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd


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


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


ans = reduce(lcm, lst_T)


print(ans)

Submission status: Accepted

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


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


N = int(input())
lst_T = [int(input()) for _ in range(N)]
ans = 1


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


print(ans)

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math




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


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

Submission status: Accepted

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

(例)
T0 = 2
T1 = 3

直感的に、最小公倍数が答え。
よって6。
"""
from fractions import gcd
from functools import reduce


def lcm(a, b):
    """ aとbの最小公倍数を返す """
    return a*b // gcd(a, b)

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

(例)
T0 = 2
T1 = 3

最小公倍数が答え。
よって6。
"""
from fractions import gcd
from functools import reduce


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

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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


n = int(input())
ans = 1
l = [int(input()) for i in range(n)]

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

Submission status: Accepted

Solution code:
import sys
import bisect
input = sys.stdin.readline

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

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

t = L[0]
for i in range(1, N):
    p = gcd(t, L[i])
    t = t * L[i] // p
    
print(t)

Submission status: Accepted

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

n=int(input())
s=int(input())
for _ in range(n-1):
  tmp=int(input())
  s=(s*tmp)//gcd(s,tmp)
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
def gcd(x, y):
	while y > 0:
		x, y = y, x % y
	return x
def lcm(x, y):
	return x * y // gcd(x, y)
print(reduce(lcm, [int(input()) for _ in range(int(input()))]))

Submission status: Accepted

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

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

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

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


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


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


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

print(ans)

Submission status: Accepted

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

p=t[0]
for k in range(1,n):
    p=lcm(p,t[k])

print(p)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc070/tasks/abc070_c
import fractions
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans  = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)

# gcd(a,b) * lcm(a,c) = a, b

Submission status: Accepted

Solution code:
from fractions import gcd

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

Submission status: Accepted

Solution code:
from fractions import gcd

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