Problem p02793 (python)

Fixed submission:
from fractions import gcd
 
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
    l = i * l // (gcd(i, l))
 
cnt = 0
for i in a:
    cnt += l // i
print(cnt % mod)

Buggy submission (verdict: Runtime Error):
import fractions
n= int(input())
a =list(map(int, input().split()))

a0 = min(a)
b0 = a0

if(n==1):
    print(1)
    exit()

for i in a:
    b0 = (b0 * i) // fractions.gcd(b0,i)
b0 = b0 / a0
count = 0
for i in a:
    count += a0*b0 // i
    count = count % (10**9 + 7)

print(count)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n= int(input())
a =list(map(int, input().split()))

a0 = min(a)

def lcm(a):
    x = 1
    for i in a:
        x = (x * i) // gcd(x,i)
    return x

l = lcm(a) // a0

count = 0
for i in a:
    count += int(l*a0/i)
    count = count % (1000000007)
    
print(count)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n= int(input())
a =list(map(int, input().split()))

def lcm(a):
    x = 1
    for i in a:
        x = (x * i) // gcd(x,i)
        
    return x

l = lcm(a)

count = 0
for i in a:
    count += int(l/i)
    count = count % (1000000007)
    
print(count)

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

n = int(input())
a = list(map(int, input().split()))

a0 = min(a0)

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)/a0
count = 0
for i in range(len(a)):
    count += int(l*a0/a[i])
    count = count % (1000000007)
print(count)

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

n = int(input())
a = list(map(int, input().split()))

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(map(int, input().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

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

n = int(input())
a = list(map(int, input().split()))

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)

l = lcm_list(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a)

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

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

l = 1
# for i in range(len(a)):
#     if(l>a[i]):
#         l = lcm(l,a[i])
#     else:
#         l = lcm(a[i],l)

l = np.lcm.reduce(a)

count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)