Problem p02793 (python)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))

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

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())

Buggy submission (verdict: Runtime Error):
import fractions


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


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = arr[0]
for i in range(1, n):
    g = lcm(g, arr[i])

answer = 0
for i in range(n):
    answer += g / arr[i]

print(int(answer % mod))

Buggy submission (verdict: Runtime Error):
import fractions


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


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = arr[0]
for i in range(1, n):
    g = lcm(g, arr[i])

answer = 0
for i in arr:
    answer += g / i

print(int(answer % mod))

Buggy submission (verdict: Runtime Error):
from math import gcd


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


def greatLCM(a):
    if len(a) < 2:
        return a[0]
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i

print(int(answer % mod))

Buggy submission (verdict: Runtime Error):
from fractions import gcd


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


def greatLCM(a):
    if len(a) < 2:
        return a[0]
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= mod

print(int(answer))

Buggy submission (verdict: Runtime Error):
from math import gcd


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


def greatLCM(a):
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= 10 ** 9 + 7

print(int(answer))

Buggy submission (verdict: Runtime Error):
from fractions import gcd


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


def greatLCM(a):
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= 1e9 + 7

print(int(answer))

Buggy submission (verdict: Runtime Error):
from math import gcd


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


def greatLCM(a):
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= 1e9 + 7

print(int(answer))