Problem p02814 (python)

Fixed submission:
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    tmp_a = a[i]
    while tmp_a % 2 == 0:
        tmp_a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Buggy submission (verdict: Runtime Error):
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    a = a[i]
    while a % 2 == 0:
        a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Buggy submission (verdict: Runtime Error):
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))
a = set(a)

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    a = a[i]
    while a % 2 == 0:
        a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Buggy submission (verdict: Runtime Error):
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)
ans = 0
a = 1
while True:
    if lc * a <= m:
        ans += 1
        a += 2
    else:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)
# ans = 0
# a = 1
# while True:
#     if lc * a <= m:
#         ans += 1
#         a += 2
#     else:
#         break
#
# print(ans)

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Buggy submission (verdict: Runtime Error):
import fractions
import functools

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / fractions.gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)

ans = m // lc
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

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


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / math.gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


n, m = map(int, input().split())

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

half_lcm = lcm / 2
ans = 0
flg = False
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))

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

n, m = map(int, input().split())

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

half_lcm = lcm / 2
ans = 0
flg = False
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))

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

n, m = map(int, input().split())

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

half_lcm = lcm / 2
ans = 0
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))