Problem p03633 (python)

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

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


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

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

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

def lcm_base(x, y):
    x_y = x * y
    gcd_xy = gcd(x, y)
    ans = int(x_y / gcd_xy)
    return ans

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

print(T[N - 1])

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

import math

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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


def lcm_base(x, y):
    x_y = x * y
    gcd_xy = math.gcd(x, y)
    ans = int(x_y / gcd_xy)
    return ans

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

print(T[N - 1])

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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


def lcm_base(x, y):
    x_y = x * y
    gcd_xy = math.gcd(x, y)
    ans = int(x_y / gcd_xy)
    return ans

'''
def lcm_list(list):
    ans = reduce(lcm_base, list, 1)
    return ans
lcm = lcm_list(T)
'''


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

print(T[N - 1])

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

def lcm_base(x, y):
    x_y = x * y
    gcd_xy = math.gcd(x, y)
    ans = int(x_y / gcd_xy)
    return ans

def lcm_list(list):
    ans = reduce(lcm_base, list, 1)
    return ans

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

def lcm_base(x, y):
    x_y = x * y
    gcd_xy = math.gcd(x, y)
    ans = int(x_y / gcd_xy)
    return ans

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

def lcm_base(x, y):
    x_y = x * y
    gcd_xy = math.gcd(x, y)
    ans = x_y // gcd_xy
    return ans

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

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

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

# 最小公倍数を求める問題
# 参考：https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

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

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
from functools import reduce
import math


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

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

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math

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

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

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

lcm = lcm_list(T)

print(lcm)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math

# 最小公倍数を求める問題だ！！
# 参考：
# https://note.nkmk.me/python-gcd-lcm/
# 上記リンク先に最大公約数も載ってた

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

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

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

lcm = lcm_list(T)

print(lcm)