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):
from math import gcd, ceil
import sys
N,M = map(int, input().split())
a = list(map(int, input().split()))
tmp = 1
for i in range(N):
    tmp = tmp * (a[i]//2) // gcd(tmp, (a[i]//2))
for i in range(N):
    if tmp // a[i] % 2 == 0:
        print(0)
        sys.exit()
print(ceil((M // tmp) / 2))

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import math
tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
allo=1
for i in range(N):
    allo&=(lcm//a[i])%2
if allo:
    print((M//lcm+1)//2)
else:
    print(0)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import math
import sys

tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        sys.exit()
print((M//tmp+1) // 2)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import math
import sys

tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        sys.exit()
print(ceil((M // tmp) / 2))

from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in range(n):
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in range(n):
    if tmp // (a[i]//2) % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import fractions

lcm = a[0]//2

for i in range(1, N):
    lcm = lcm * (a[i]//2) // fractions.gcd(lcm, a[i]//2)

if (M//lcm)%2 == 0:
    print(M//lcm//2)
else:
    print((M//lcm+1)//2)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import fractions

lcm = a[0]//2

for i in range(1, N):
    lcm = lcm * (a[i]//2) // fractions.gcd(lcm, a[i]//2)

print(-(-(M//lcm) // 2))

from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in a:
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import fractions

ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
if ans > M*2:   
    print(0)
else:
    print(int(M/ans)+1)

from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in a]
l = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)


N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import fractions
import sys

lcm = a[0]//2

for i in range(1, N):
    lcm = lcm * (a[i]//2) // fractions.gcd(lcm, a[i]//2)

    
count_list = []
count = 0
for i in range(N):
    while a[i] % 2 == 0:
        count += 1
        a[i] = a[i] // 2
    count_list.append(count)
    count = 0
    
for i in range(N):
    if count_list[i] != sum(count_list)/N:
        print(0)
        sys.exit()
    

print(-(-(M//lcm) // 2))

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

import fractions

lcm = a[0]//2

for i in range(1, N):
    lcm = lcm * (a[i]//2) // fractions.gcd(lcm, a[i]//2)


print(M//lcm//2)

from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in A]
lcd = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Time Limit Exceeded

Wrong Answer

Accepted