Problem p03633 (python)

Fixed submission:

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


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))

Buggy submission (verdict: Runtime Error):

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


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))

Buggy submission (verdict: Runtime Error):

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


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))

Buggy submission (verdict: Runtime Error):

def euclid(a, b):
    r = a % b
    if 0 == r:
        return b
    return max(1, euclid(b, r))


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


def greatest_common_divisor_arr(arr):
    if 1 == n:
        return arr[0]
    else:
        d = greatest_common_divisor(arr[0], arr[1])
        for i in range(2, n):
            d = greatest_common_divisor(d, arr[i])
        return d


n = int(input())
ans = greatest_common_divisor_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))

Buggy submission (verdict: Runtime Error):

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


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


def greatest_common_divisor_arr(arr):
    if 1 == n:
        return arr[0]
    else:
        d = greatest_common_divisor(arr[0], arr[1])
        for i in range(2, n):
            d = greatest_common_divisor(d, arr[i])
        return d


n = int(input())
ans = greatest_common_divisor_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))

Buggy submission (verdict: Runtime Error):

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


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


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

if 1 == n:
    print(t[0])
elif 2 == n:
    print(greatest_common_divisor(t[0], t[1]))
else:
    d = greatest_common_divisor(t[0], t[1])
    for i in range(2, n):
        d = greatest_common_divisor(d, t[i])
    print(d)

Buggy submission (verdict: Runtime Error):

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


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


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

if 1 == n:
    print(t[0])
elif 2 == n:
    print(greatest_common_divisor(t[0], t[1]))
else:
    d = greatest_common_divisor(t[0], t[1])
    for i in range(2, len(t)):
        d = greatest_common_divisor(d, t[i])
    print(d)

Buggy submission (verdict: Runtime Error):

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


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


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

if 1 == n:
    print(t[0])
else:
    d = greatest_common_divisor(t[0], t[1])
    for i in range(2, len(t)):
        d = greatest_common_divisor(d, t[i])
    print(d)