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: Time Limit Exceeded

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    clocks = inputs
    clocks.sort()

    max_c = clocks.pop()
    count = max_c
    while count <= 10 ** 18:
        fin = count
        for c in clocks:
            if count % c != 0:
                fin = None
                break
        if fin is not None:
            return count
        count += max_c


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(int_inputs(N))
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
t = [int(input()) for _ in range(n)]
t_max = max(t)
i = 1
while t_max * i <= 10 ** 18:
    for ti in t:
        if (t_max * i) % ti != 0:
            break
    else:
        print(t_max * i)
        break
    i += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
t = [int(input()) for _ in range(n)]
t_max = max(t)
for i in range(10 ** 18 // t_max):
    for ti in t:
        if (t_max * (i + 1)) % ti != 0:
            break
    else:
        print(t_max * (i + 1))
        exit()

Submission status: Time Limit Exceeded

Solution code:
def LCM(x, y):
   if x > y:
       greater = x
   else:
       greater = y
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
   return lcm
n = int(input())
lst = []
for i in range(n):
    lst.append(int(input()))
for i in range(1, n):
    lst[i] = LCM(lst[i-1], lst[i])
print(lst[n-1])

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
s = set()
d = dict()
for i in range(n):
    c = collections.Counter(f(int(input())))
    for x,y in zip(c.keys(),c.values()):

        if x not in s :
            s.add(x)
            d[x] = y
        else:
            d[x] = max(y,d[x])
b = [ x**y for x,y in zip(d.keys(),d.values())]
ans = 1
for i in b:
    ans *= i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(set([int(input()) for d in range(n)]))  
a=l[0]
sd=0
for i in l[1:]:
  for h in range(min(i,a)+1)[:0:-1]:
    if (a%h,i%h)==(0,0):
      sd=h
      break
  a=a*i//sd
print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(set([int(input()) for d in range(n)]))
def gcd(a,s):
  for i in range(min(a,s)+1)[:0:-1]:
    if (a%i,s%i)==(0,0):
      return i

    
a=l[0]
for i in l[1:]:
  g=gcd(a,i)
  a=a*i//g
print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
N = int(input())
T = sorted(list(set([int(input()) for _ in range(N)])), reverse=True)
ret = 1
while len(T) > 1:
  C = int(max(T) ** 0.5)
  f = False
  for c in range(2, C + 1):
    T_ = deque([])
    for i, t in enumerate(T):
      if t % c == 0:
        T_.append(t // c)
        f = True
      elif t < c:
        ret *= t
      else:
        T_.append(t)
    T = sorted(list(set([t for t in T_ if t >= c])), reverse=True)
    if f:
      ret *= c
      break
  else:
    break
for t in T:
  ret *= t
print(ret)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = sorted(list(set([int(input()) for _ in range(N)])), reverse=True)
ret = 1
while len(T) > 1:
  C = int(max(T) ** 0.5)
  f = False
  for c in range(2, C + 1):
    T_ = []
    for i, t in enumerate(T):
      if t % c == 0:
        T_.append(t // c)
        f = True
      elif t < c:
        ret *= t
      else:
        T_.append(t)
    T = sorted(list(set([t for t in T_ if t >= c])), reverse=True)
    if f:
      ret *= c
      break
  else:
    break
for t in T:
  ret *= t
print(ret)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = sorted(list(set([int(input()) for _ in range(N)])), reverse=True)
ret = []
while len(T) > 1:
  C = int(max(T) ** 0.5)
  f = False
  for c in range(2, C + 1):
    if T[-1] < c:
      ret.append(T[-1])
      T = T[:-1]
    T_ =  T[:]
    for i, t in enumerate(T):
      if t % c == 0:
        T_[i] = t // c
        f = True
    if f:
      ret.append(c)
      T = sorted(list(set(T_[:])), reverse=True)
      break
  else:
    break

ret += T
ans = 1
for r in ret:
  ans *= r
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

time_array = []
for i in range(N):
    time_array.append(int(input()))
#print(time_array)

base_num = max(time_array)

canContinue = True
ans = 0
while canContinue:
    ans += base_num
    canContinue = False
    for time in time_array:
        if ans % time == 0:
            pass
        else:
            canContinue = True
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = set([_I() for _ in range(N)])

times = 1
max_v = max(T)
new_T = []
for t in T:
    if max_v % t != 0:
        new_T.append(t)
T = new_T
while True:
    max_t = max_v * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = set([_I() for _ in range(N)])

times = 1
max_v = max(T)
while True:
    max_t = max_v * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = [_I() for _ in range(N)]

times = 1
max_v = max(T)
while True:
    max_t = max_v * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = [_I() for _ in range(N)]

times = 1
while True:
    max_t = max(T) * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break

Submission status: Time Limit Exceeded

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

t = sorted(t)[::-1]
biggest = t[0]
for i in range(biggest, 10**18+1, biggest):
    ok = True
    for j in t[1:]:
        if i%j != 0:
            ok = False
            break
    if ok == True:
        break
    
print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

max_val = max(A)

while True:
	flag = True
	for a in A:
		if max_val%a != 0:
			flag = False
			break
	if flag:
		break
	max_val += max_val

print(max_val)

Submission status: Time Limit Exceeded

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

T = A[0]
for i in range(1, N):
    t = A[i]
    now_T = T
    while(True):
        if t % T == 0:
            T = t
            break
        elif T % t == 0:
            break
        T += now_T
print(T)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    now_T = T
    while(True):
        if t % T == 0:
            T = t
            break
        elif T % t == 0:
            break
        T += now_T
print(T)

Submission status: Time Limit Exceeded

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

main_t = max(T)
cur = main_t
flag = True
while 1:
	for t in T:
		if cur%t != 0:
			flag = False
			break
	if flag:
		ans = cur
		break
	cur += main_t
	flag = True
	# print(cur)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
g = int(input())
for _ in range(n-1):
    t = int(input())
    r = max(t, g)
    l = min(t, g)
    i = 1
    while True:
        if (r*i) % l == 0:
            g = r * i
            break
        i += 1
print(g)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt, ceil

N = int(input())

def factorize(n):
    s = {}
    while n != 1:
        orig = n
        lim = ceil(sqrt(n))
        i = 2
        while n != 1 and i <= lim:
            d, r = divmod(n, i)
            if r != 0:
                i += 1
                continue
            s[i] = s[i] + 1 if i in s.keys() else 1
            n = d
        if orig == n:
            s[orig] = s[orig] + 1 if orig in s.keys() else 1
            break
    return s

def merge(a, b):
    for k, v in b.items():
        a[k] = max(a[k], b[k]) if k in a.keys() else b[k]
    return a

def main():
    fac = {}
    for _ in range(N):
        t = int(input())
        fac = merge(fac, factorize(t))
    ans = 1
    for k, v in fac.items():
        ans *= k ** v
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

pnmax = {}

def pn(A):
	a = A
	for n in range(2, A + 1):
		if a == 1:
			return
		c = 0
		while not a % n:
			c += 1
			a //= n
		if 0 < c:
			if not n in pnmax:
				pnmax[n] = c
			else:
				pnmax[n] = max(pnmax[n], c)

for t in T:
	pn(t)

r = 1
for k, v in pnmax.items():
	r *= k ** v

#print(pnmax)
print(r)

Submission status: Time Limit Exceeded

Solution code:
def min_mult(a, b):
    result = max(a, b)
    while result % min(a, b) != 0:
        result += max(a, b)
    return result
N = int(input())
multiple = 1
for _ in range(N):
    multiple = min_mult(multiple, int(input()))
print(multiple)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
sorted_T = sorted(T, key = lambda x: -x)
time = sorted_T[0]
for t in sorted_T:
    if time % t != 0:
        time *= t
while time >= sorted_T[0]:
    flag = True
    for t in T:
        if time % t != 0:
            flag = False
            break
    if flag:
        result = time
    time -= sorted_T[0]
print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
max_T = 1
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
    max_T = max(max_T, t)
time = max_T
while time <= 10**18:
    flag = True
    for t in T:
        if time % t != 0:
            flag = False
            break
    if flag == True:
        print(time)
        break
    else:
        time += max_T

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li_t = list()

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

li_sorted = sorted(li_t, reverse=True)
t_max = li_sorted.pop(0)


sec = 1
while(True):
    if all(map(lambda x: (t_max * sec) % x == 0, li_sorted)):
        print(sec * t_max)
        exit(0)
    else:
        sec += 1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]
T.sort()
while True:
    flag = False
    for i in range(N-1):
        if T[-1]%T[i]!=0:
            T[-1] += T[-1]
            flag = True
            break
    if flag == False:
        print(T[-1])
        break

Submission status: Time Limit Exceeded

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

ssum = {}
def func(a):
	global ssum
	s = {}
	for i in range(2, a + 1):
		while not a % i:
			if i not in s:
				s[i] = 1
			else:
				s[i] += 1
			a //= i
		if 1 == a:
			break
	for t in s:
		if t not in ssum:
			ssum[t] = s[t]
		else:
			ssum[t] = max(ssum[t], s[t])

for t in T:
	func(t)

r = 1
for t in ssum:
	r *= t ** ssum[t]

print(r)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = []
for i in range(N):
    t = int(input())
    if t not in T:
        T.append(t)
time = 0
mag = 0
while True:
    mag += 1
    for t in T:
        if max(T) * mag % t == 0:
            pass
        else:
            break
    if max(T) * mag % t == 0:
        time = max(T) * mag
        break
print(time)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]
_T = []
for t in T:
    if t not in _T:
        _T.append(t)
time = 0
mag = 0
while True:
    mag += 1
    for t in _T:
        if max(T) * mag % t == 0:
            pass
        else:
            break
    if max(T) * mag % t == 0:
        time = max(T) * mag
        break
print(time)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]
time = 0
mag = 0
while True:
    mag += 1
    for t in T:
        if max(T) * mag % t == 0:
            pass
        else:
            break
    if max(T) * mag % t == 0:
        time = max(T) * mag
        break
print(time)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
T=[int(input()) for i in range(N)]
T.sort(reverse=True)
ans=T[0]
for i in range(1,N):
    t=T[i]
    now=ans
    while now%t!=0:
        now+=ans
    ans=now
print(ans)

Submission status: Time Limit Exceeded

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

T = list(set(T))
T.sort(reverse=True)

T_max = T[len(T) - 1]
count = 1
flag_1 = True
while flag_1:
    check = T_max * count 
    flag_2 = True
    for i in T:
        if check % i != 0:
            flag_2 = False
            break
    if flag_2 == True:
        print(T_max * count)
        flag_1 = False
    count += 1

Submission status: Time Limit Exceeded

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

T = sorted(list(set(T)))

T_max = T[len(T) - 1]
count = 1
flag_1 = True
while flag_1:
    check = T_max * count 
    flag_2 = True
    for i in T:
        if check % i != 0:
            flag_2 = False
            break
    if flag_2 == True:
        print(T_max * count)
        flag_1 = False
    count += 1

Submission status: Time Limit Exceeded

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

T = sorted(list(set(T)))
T_max = T[len(T) - 1]
count = 1
flag_1 = True
while flag_1:
    check = T_max * count 
    flag_2 = True
    for i in T:
        if check % i != 0:
            flag_2 = False
    if flag_2 == True:
        print(T_max * count)
        flag_1 = False
    count += 1

Submission status: Time Limit Exceeded

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


x = 1
M = max(cycles)
while 1:
    for num in cycles:
        if (M * x) % num != 0:
            x += 1
            break
    else:
        print(M * x)
        quit()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	num = int(input())
	
	clocks = []
	for _ in range(num):
		clock = int(input())
		clocks.append(clock)
		
	clock_max_i = clocks.index(max(clocks))
	times = copy.deepcopy(clocks)
	while True:
		flg = True
		max_num = max(times)
		for i, time in enumerate(times):
			if max_num == time : continue
			
			tmp = max_num // clocks[i]
			times[i] = clocks[i] * tmp
			if max_num != times[i]:
				flg = False
			
		if flg:
			print(times[0])
			sys.exit()
		else:
			times[clock_max_i] = times[clock_max_i] + clocks[clock_max_i]
			
if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	num = int(input())
	
	clocks = []
	for _ in range(num):
		clock = int(input())
		clocks.append(clock)
		
	times = copy.deepcopy(clocks)
	while True:
		flg = True
		max_num = max(times)
		for i, time in enumerate(times):
			if max_num == time : continue
			
			tmp = max_num // time
			times[i] = times[i] * tmp
			if max_num != times[i]:
				flg = False
			
		if flg:
			print(times[0])
			sys.exit()
		else:
			p = times.index(max_num)
			times[p] = times[p] + clocks[p]
			max_num = times[p]
			
if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	num = int(input())
	
	clocks = []
	for _ in range(num):
		clock = int(input())
		clocks.append(clock)
		
	times = copy.deepcopy(clocks)
	while True:
		max_num = max(times)
		for i, time in enumerate(times):
			if max_num == time : continue
			
			tmp = max_num // time
			times[i] = times[i] * tmp
			
		flg = True
		num = times[0]
		for time in times:
			if num != time:
				flg = False
				
		if flg:
			print(num)
			sys.exit()
		else:
			for i, time in enumerate(times):
				if max_num == time:
					times[i] = times[i] + clocks[i]
					max_num = times[i]
					break
			
if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())




"""
公倍数を求める

"""

class Num:
    def __init__(self, number):
        self.number = number
        self.divisor = []
        self.multiple = []
        self.factors = {}

    def calc_divisor(self):
        for i in range(self.number):
            if i == 0:
                continue
            else:
                if i % self.number == 0:
                    self.divisor.append(i)

    def factorize(self):
        num = self.number
        while True:
            for i in range(num + 1):
                if i == 0 or i == 1:
                    continue
                else:
                    if num % i == 0:
                        if i not in self.factors:
                            self.factors[i] = 1
                        else:
                            self.factors[i] += 1
                        num = num / i
                        num = int(num)
                        break
            if num == 1:
                break


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


def calc_common_multiple(numbers):
    for number in numbers:
        number.factorize()

    all_keys = []
    for number in numbers:
        for key in number.factors.keys():
            all_keys.append(key)

    all_keys = list(set(all_keys))

    for key in all_keys:
        for number in numbers:
            if key not in number.factors:
                number.factors[key] = 0

    for key in all_keys:
        values = []
        for number in numbers:
            values.append(number.factors[key])

        max_value = max(values)
        for number in numbers:
            number.factors[key] = max_value

    result = 1
    for key, value in numbers[0].factors.items():
        result *= key ** value

    return result



print(calc_common_multiple(numbers))

Submission status: Time Limit Exceeded

Solution code:
#C問題　importがない場合
#最小公倍数
N=int(input())
T=[]
for i in range(0,N):
    T.append(int(input()))
def gcd(x,y):
    gcd=1
    for i in range(2,x+1):
        if x%i==0 and y%i==0:
            gcd=i
    return gcd
def lcm_base(x,y):
    return (x*y)//gcd(x,y)
def lcm_reduce(T):
    result=T[0]
    for i in range(1,len(T)):
        result=lcm_base(result,T[i])
    return result
print(lcm_reduce(T))

Submission status: Time Limit Exceeded

Solution code:
#ABC070-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

def fctr1(n): #[[素因数,数]]を出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

n=I()
t=[]
elm=dict()
for i in range(n):
    tmp=I()
    t.append(tmp)
for i in range(n):
    f=fctr1(t[i])
    for j in f:
        if j[0] in elm:
            elm[j[0]]=max(elm[j[0]],j[1])
        else:
            elm[j[0]]=j[1]
ans=1
for i in elm:
    ans*=pow(i,elm[i])
print(ans)

Submission status: Time Limit Exceeded

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

m = max(T)
mm = m
while True:
    flg =False
    for j in range(N):
        if m % T[j] != 0:
            flg = True
            break
    if flg == True:
        m += mm
    else:
        print(m)
        exit()

Submission status: Time Limit Exceeded

Solution code:
def factoring(n):
    if n == 1:
        return dict()
    p = 2
    tmp1 = int(n**0.5)
    ret = {}
    tmp = 0
    while n != 1:
        if n % p == 0:
            n //= p
            tmp += 1
        elif p > tmp1:
            ans_dic[p] = max(ans_dic.get(p, 0), tmp)
            p = n
            tmp = 0
        else:
            ans_dic[p] = max(ans_dic.get(p, 0), tmp)
            p += 1
            tmp = 0
    ans_dic[p] = max(ans_dic.get(p, 0), tmp)
    return ret


N = int(input())
A = [int(input()) for _ in range(N)]
ans_dic = {}
for a in A:
    factoring(a)

ret = 1
for k, v in ans_dic.items():
    ret *= k**v
print(ret)

Submission status: Time Limit Exceeded

Solution code:
def factoring(n):
    if n == 1:
        return dict()
    p = 2
    tmp = int(n**0.5)
    ret = {}
    while n != 1:
        if n % p == 0:
            n //= p
            ret[p] = ret.get(p, 0) + 1
        elif p > tmp:
            p = n
        else:
            p += 1
    return ret
            

def func(ans, b):
    B = factoring(b)
    # print(ans, B)
    return {i:max(ans.get(i, 0), B.get(i, 0)) for i in set(ans) | set(B)}

N = int(input())
A = [int(input()) for _ in range(N)]
ans = {}
for a in A:
    ans = func(ans, a)

ret = 1
for k, v in ans.items():
    ret *= k**v
print(ret)

Submission status: Time Limit Exceeded

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N = int(input())
T = [int(input()) for _ in range(N)]
T = deque(sorted(T,reverse=True))
mx = T[0]
T.popleft()
time = 0
while(1):
    time += 1
    count = 0
    for v in T:
        if (mx * time) % v == 0:
            count += 1
        else:
            break
    if N - 1 == count:
        break
print(mx * time)

Submission status: Time Limit Exceeded

Solution code:
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = []
for i in range(a):
    l = int(input())
    ar.append(l)
b = max(ar)
ans = "F"
count = 0
c = max(ar)
while ans == "F":
    for r in ar:
        if c % r == 0:
            count += 1
    if count == a:
        print(c)
        ans = "T"
    else:
        c += b
    count = 0

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))
i = 0
while True:
    i+=1
    flag = True
    for j in range(n):
        if (i*max(t))%t[j] != 0:
            break
        if j == n-1:
            flag = False
    if flag == False:
        break
print(i*max(t))

Submission status: Time Limit Exceeded

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

for i in range(1, N):
    a = 1
    while True:
        if (result * a) % T[i] == 0:
            result *= a
            break
        a += 1

print(result)

Submission status: Time Limit Exceeded

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

a = T[0]
i =1
while True:
  if sum(map(lambda x:T[0]%x, T)) !=0:
    T[0] += a
  else:
    print(T[0])
    exit()
  i += 1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Amax = max(A)

i = 1
while i * Amax <= 1e18:
  fl = False
  for a in A:
    if i * Amax % a != 0:
      fl = True
      break
  if fl:
    i += 1
    continue
  else:
    break

print(i*Amax)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Amax = max(A)

i = 1
while i * Amax <= 1e18:
  fl = False
  for a in A:
    if i * Amax % a != 0:
      fl = True
      continue
  if fl:
    i += 1
    continue
  else:
    break

print(i*Amax)

Submission status: Time Limit Exceeded

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

m = max(T)
mm = m
flg = False
while True:
    for i in T:
        if m % i != 0:
            flg =True

    if flg == False:
        break
    flg = False
    m += mm

print(m)

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
m = {}
for i in range(N):
  ti = int(raw_input())
  pi = {}
  x = 2
  while x*x <= ti:
    while ti % x == 0:
      ti /= x
      pi[x] = pi.get(x,0)+1
    x += 1
  if ti > 1:
    pi[ti] = pi.get(ti,0)+1
  for x in pi.keys():
    m[x] = max(m.get(x,0), pi[x])
ret = 1
for x in m.keys():
  ret *= x**m[x]
print ret

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
a.sort(reverse=True)
maxi = a[0]
j = 1
k = 1
while k <= len(a)-1:
  if (j*maxi)%a[k] == 0:
    k += 1
  else:
    k = 1
    j += 1
print(j*maxi)

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin

n = int(stdin.readline())
t = [0]*n
for i in range(n):
    t[i] = int(stdin.readline())

max = max(t)
ok = 0
t_max = max
while True:
    for i in t:
        if max % i == 0:
            ok += 1
        else:
            break
    if ok == n:
        t_max = max
        break
    max *= 2
    ok = 0

print(t_max)

# 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: Time Limit Exceeded

Solution code:
N=int(input())
s=[int(input()) for i in range(N)]
i=0
while i>=0 :
    i+=1
    for j in range(N):
        if (max(s)*i)%s[j]!=0:
            break
    else:
        print(max(s)*i)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
t = []
for i in range(n):
  t.append(int(input()))
max = max(t)
base = max
count = 0
x = 1
while not count == n:
  base = max*x
  count = 0
  for i in t:
    if base % i == 0:
      count += 1
  
  x += 1

print(max*(x-1))

Submission status: Time Limit Exceeded

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

Tmax = max(T)
count = 1

while True:
    can = Tmax * count
    
    for Ti in T:
        if can%Ti!=0:
            break
    else:
        print(can)
        break
        
    count += 1