Problem: Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.  Let a _semi-common multiple_ of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):    * There exists a non-negative integer p such that X= a_k \times (p+0.5).  Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Submission attempts (in order):
import fractions
import math

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
        if m < L:
            print(0)
            break

    print(int(math.ceil(m / L) // 2))
else:
    print(0)


import numpy as np
import math
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

while all(a % 2 == 0):
    a = a / 2

ans = 0
for i in a:
    if i % 2 == 0:
        ans = 0
        break
    else:
        ans = math.ceil((math.floor(m / lcm(*a))) / 2)
        if lcm(*a) == 1:
            ans -= 1

print(int(ans))


import numpy as np
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a_d = a // 2

ans = m / lcm(*a_d) / 2
if ans.is_integer():
    ans = m // lcm(*a_d) // 2 - 1
    print(int(ans))
else:
    ans = round(m / lcm(*a_d) / 2)
    print(int(ans))

import fractions
import math

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break
    print(int((m // L + 1) // 2))
else:
    print(0)

import fractions
import math

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
        if m < L:
            print(0)
            break

    print(int((m // L + 1) // 2))
else:
    print(0)


import numpy as np
import math
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a_d = a // 2

for i in a_d:
    if i % 2 == 0:
        ans = 0
        break
    else:
        ans = math.ceil(m / lcm(*a_d) / 2)

print(int(ans))

import fractions

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
    if m < L:
        print(0)
    else:
        print(int((m // L) - (m // (2 * L))))
else:
    print(0)


from fractions import gcd

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break

    print((m // L + 1) // 2)
else:
    print(0)


import sys
from math import gcd
from copy import deepcopy

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    A_ = deepcopy(A)
    cnt = [0] * n
    for i in range(n):
        while A_[i] % 2 == 0:
            A_[i] //= 2
            cnt[i] += 1
        if i != 0 and cnt[i] != cnt[i - 1]:
            print(0)
            exit()

    L = 1
    for a in A:
        L = lcm(L, a // 2)

    res = m // L - (m // (L * 2))
    print(res)


if __name__ == '__main__':
    resolve()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted