Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

#def lcm(A, n):
#    if n == 2:
#        return A[0]*A[1] // gcd(A[0], A[1])
#    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
#    a = lcm(A, n-1)
#    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
#a = []
T1 = int(input())
for i in range(n-1):
    T2 = int(input())
    T1 = T1*T2 // gcd(T1, T2)
    #a.append(int(input()))
#a.sort(reverse = True)
#ans = lcm(a, n)
print(str(T1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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

def lcm(A, n):
    if n == 2:
        return A[0]* (A[1] // gcd(A[0], A[1]))
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    rec = lcm(A, n-1)
    return rec * (A[n-1] // gcd(rec, A[n-1]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
ans = lcm(a, n)
print(str(ans))

#通るコード
#n = int(input())
#T1 = int(input())
#for i in range(n-1):
#    T2 = int(input())
#    T1 = T1*T2 // gcd(T1, T2)
#print(str(T1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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

def lcm(A, n):
    if n == 2:
        return A[0]* (A[1] // gcd(A[0], A[1]))
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    temp = lcm(A, n-1)
    return temp * (A[n-1] // gcd(temp, A[n-1]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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

def lcm(A, n):
    if n == 2:
        return A[0]* (A[1] // gcd(A[0], A[1]))
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a * (A[n-1] // gcd(a, A[n-1]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 1:
        return 1
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 1:
        return 1
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n-1):
    a.append(int(input()))
#a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]* (A[1] // gcd(A[0], A[1]))
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a* (A[n-1] // gcd(a, A[n-1]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a*A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a // b
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a*A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))