Problem:


Score : 400 points

Problem Statement

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).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
if count_even == N:
    x //= 2
    for i in x[1:]:
        if x[0] != i:
            print(0)
            sys.exit()

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)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
import math
import fractions


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


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


def f(x):  # 2で割れる回数
    c = 0
    while x % 2 == 0:
        x //= 2
        c += 1
    return c


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(set(a))

    # a -> a'
    for i in range(len(a)):
        if a[i] % 2 == 1:
            print(0)
            return
        a[i] //= 2

    # a' -> a''
    t = f(a[0])
    for i in range(len(a)):
        if(f(a[i]) != t):
            print(0)
            return
        a[i] = a[i] // 2**t

    l = 1
    for i in range(len(a)):
        l = lcm_base(l, a[i])
        if l > m:
            print(0)
            return

    m = m // l
    ans = (m+1)//2
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import fractions
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

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

ma = 0
mod2count = 0
for i in range(n):
    a[i] = a[i] // 2
    if a[i] > ma:
        ma = a[i]
    if ((a[i] != 0) and not(a[i] & (a[i]-1))) or a[i] == 1:
        mod2count += 1

l = a[0]
for i in range(1, n):
    l = lcm(l, a[i])

if mod2count >= 2:
    print(0)
    exit(0)

tmp = m // l
if tmp % 2 == 0:
    print(tmp // 2)
else:
    print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import math
import fractions


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


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


def f(x):  # 2で割れる回数
    c = 0
    while x % 2 == 0:
        x /= 2
        c += 1
    return c


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(set(a))

    # a -> a'
    for i in range(len(a)):
        if a[i] % 2 == 1:
            print(0)
            return
        a[i] /= 2

    # a' -> a''
    t = f(a[0])
    for i in range(len(a)):
        if(f(a[i]) != t):
            print(0)
            return
        a[i] = a[i] / 2**t

    l = 1
    for i in range(len(a)):
        l = lcm_base(l, a[i])
        if l > m:
            print(0)
            return

    m = math.floor(m/l)
    ans = (m+1)/2
    print(int(ans))


main()

Submission status: Wrong Answer

Solution code:
import fractions
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

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

ma = 0
mod2count = 0
for i in range(n):
    a[i] = a[i] // 2
    if a[i] > ma:
        ma = a[i]
    if a[i] % 2 == 0 or a[i] == 1:
        mod2count += 1

l = a[0]
for i in range(1, n):
    l = lcm(l, a[i])

if mod2count >= 2:
    print(0)
    exit(0)

tmp = m // l
if tmp % 2 == 0:
    print(tmp // 2)
else:
    print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import math
import fractions


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


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


def f(x):  # 2で割れる回数
    c = 0
    while x % 2 == 0:
        x /= 2
        c += 1
    return c


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(set(a))

    # a -> a'
    for i in range(len(a)):
        a[i] /= 2

    # a' -> a''
    t = f(a[0])
    for i in range(len(a)):
        if(f(a[i]) != t):
            print(0)
            return
        a[i] /= 2**t

    l = 1
    for i in range(len(a)):
        l = lcm_base(l, a[i])
        if l > m:
            print(0)
            return

    m = math.floor(m/l)
    ans = (m+1)/2
    print(int(ans))


main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()

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)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

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

ma = 0
is2 = 0
for i in range(n):
    if a[i] == 2:
        is2 = True
    a[i] = a[i] // 2
    if a[i] > ma:
        ma = a[i]

l = a[0]
for i in range(1, n):
    l = lcm(l, a[i])

if is2 == True and l % 2 == 0:
    print(0)
    exit(0)

tmp = m // l
if tmp % 2 == 0:
    print(tmp // 2)
else:
    print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
if count_even == N:
    for i in x[1:]:
        if i // 2 != x[0] // 2:
            print(0)
            sys.exit()


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)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
import fractions
n,m = map(int,input().split())
a = list(set(list(map(int,input().split()))))
n = len(a)
gcd = a[0]
for i in range(n):
  gcd = fractions.gcd(gcd,a[i])
half_gcd = gcd*2
lcm = gcd
half_lcm = half_gcd
for j in range(n):
  lcm *= a[j]//gcd
  half_lcm *= a[j]//half_gcd
if half_lcm > m:
  print(0)
else:
  print((m-half_lcm)//lcm+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
if x[0] % 2 == 0 and count_even == N:
    for i in x[1:]:
        if i != x[0]:
            print(0)
            sys.exit()


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)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
import fractions
n,m = map(int,input().split())
a = list(set(list(map(int,input().split()))))
n = len(a)
gcd = a[0]
for i in range(n):
  gcd = fractions.gcd(gcd,a[i])
half_gcd = gcd*2
lcm = gcd
half_lcm = half_gcd
for j in range(n):
  lcm *= a[j]//gcd
  half_lcm *= a[j]//half_gcd
print(gcd,lcm,half_gcd,half_lcm)
if half_lcm > m:
  print(0)
else:
  print((m-half_lcm)//lcm+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
if x[0] % 2 == 0:
    for i in x[1:]:
        if i != x[0]:
            print(0)
            sys.exit()


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)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(set(list(map(int,input().split()))))
AG=[a// 2 for a in A]

from fractions import gcd
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
LCL = lcm_list(AG)
ANS = 0
#print(LCL)
#print(A)
ANS = M / LCL / 2
import math
if ANS < 1:
	print(0)
else:
	print(math.ceil(ANS))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))

 #最大公約数
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
  
j_odds, j_even = 0, 0
for i in range(len(A)):
 A[i] = A[i]//2  
 if(A[i]%2 == 0): j_even = 1
 elif(A[i]%2 == 1): j_odds = 1

A = list(set(A))  
if(j_odds*j_even == 1):
  ans = 0
else:
  if(len(A) == 1):
    all_lcm = A[0]
  else:
   for i in range(len(A)):
     if(i != 0):
       if(i == 1): all_lcm = lcm(A[i-1],A[i])
       else:  all_lcm = lcm(all_lcm,A[i])
  #print(all_lcm)   
  n = M//all_lcm
  if(n%2 == 0): ans = n//2 
  else: ans = n//2 + 1
 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
count_even = np.count_nonzero((a_num // 2) % 2 == 0)
if count_even != N and count_even != 0:
    print(0)
    sys.exit()
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)

x = list(a_num // 2)
minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
cnt = [0]*N

for i in range(N):
    tmp = b[i]
    
    while tmp%2==0:
        tmp //= 2
        
    cnt[i] += 1

if len(set(cnt))!=1:
    print(0)
    exit()
    
L = 1

for bi in b:
    L = lcm(L, bi)

L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

if L>M:
    print(0)
else:
    print((M-L)//L2+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
cnt = [0]*N

for i in range(N):
    tmp = b[i]
    
    while tmp%2==0:
        tmp //= 2
        
    cnt[i] += 1

if len(set(cnt))!=1:
    print(0)
    exit()
    
L = 1

for bi in b:
    L = lcm(L, bi)

L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

print((M-L)//L2+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce

n, m = map(int, input().split())
A =[i//2 for i in list(map(int, input().split()))]

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

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


def cntTwo(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

if len(set(map(cntTwo, A))) != 1:
    print(0)
    exit()

def merge(a, b):
    l = lcm(a, b)
    if l > 10 ** 9:
        return 0
    return l

x = int(reduce(merge, A))
if x == 0:
    print(0)
else:
    print(m//x - m//(x*2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


axs = list()

for i in range(n):
    a = As[i]
    axs.append(a//2)

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    k = m//lcm
    print(k - m//(lcm*2))
       

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


axs = list()

for i in range(n):
    a = As[i]
    axs.append(a//2)

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    k = m//lcm // 2
    print(k + k%2)
       

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


axs = list()

for i in range(n):
    a = As[i]
    axs.append(a//2)

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    k = m//lcm // 2
    print(k)
       

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


axs = list()

for i in range(n):
    a = As[i]
    axs.append(a//2)

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    k = m//lcm // 2
    print(k - k%2)
       

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

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

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

N, M = map(int, readline().split())
A = list(map(int, readline().split()))

B = [a//2 for a in A]

L = 1
for b in B:
    L = lcm(L, b)

ans = 0
if all((L//b) & 1 for b in B):
    ok = 0
    ng = M
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if (med*2-1)*L <= M:
            ok = med
        else:
            ng = med
    print(ok)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


axs = list()

for i in range(n):
    a = As[i]
    axs.append(a//2)

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    k = m//lcm
    print(k - k%2)
       

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

a = 0

B = [0] * n
for i in range(n):
    while A[i] % 2 == 0:
        A[i] //= 2
        B[i] += 1

if len(set(B)) != 1:
    print(0)
else:
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print("b", b)

    # b=np.lcm.reduce(A)

    ans = (m//b + 1) // 2
    # if (m//(b*2))*(b*2)+b<=m:
    #     ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

a = 0

for i in range(n):
    if A[i]%2==1:
        a = 1

for i in range(n):
        A[i] //= 2

for i in range(n):
    if A[i]%2==0:
        a = 1
if a==1:
    print(0)
else:
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print("b", b)

    # b=np.lcm.reduce(A)

    ans = (m//b + 1) // 2
    # if (m//(b*2))*(b*2)+b<=m:
    #     ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

for i in range(n):
        A[i] //= 2

a = 0

for i in range(n):
    if A[i]%2==0:
        a = 1
if a==1:
    print(0)
else:
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print("b", b)

    # b=np.lcm.reduce(A)

    ans = (m//b + 1) // 2
    # if (m//(b*2))*(b*2)+b<=m:
    #     ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print("b", b)

    # b=np.lcm.reduce(A)

    ans = (m//b + 1) // 2
    # if (m//(b*2))*(b*2)+b<=m:
    #     ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print(b)

    # b=np.lcm.reduce(A)

    ans = m//(b*2)
    if (m//(b*2))*(b*2)+b<=m:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

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

import sys

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print(b)

    # b=np.lcm.reduce(A)

    ans = m//(b*2)
    if (m//(b*2))*(b*2)+b<=m:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return y

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

import sys

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print(b)

    # b=np.lcm.reduce(A)

    ans = m//(b*2)
    if (m//(b*2))*(b*2)+b<=m:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
from operator import mul

n, m = map(int, input().split())
a = list(set(map(int, input().split())))
ah = [ai // 2 for ai in a]
lcm = reduce(mul, ah) // reduce(gcd, ah)

print(m // lcm // 2 + 1 if lcm <= m else 0)

Submission status: Wrong Answer

Solution code:
import sys

def gcd(a,b):
    if a < b:
        a,b = b,a
    while b:
        a,b = b, a % b
    return a

N,M = map(int,input().split())
A = list(map(lambda x:int(x)//2,input().split()))

m = A[0] % 2
for i in range(1,N):
    if A[i] % 2 != m:
        print(0)
        sys.exit()

ans = A[0]
for i in range(1, N):
    ans = ans * A[i] // gcd(ans, A[i])

print(M//ans-M//(ans*2))

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

def cnt_2(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2

    cnt = cnt_2(a[0])
    for i in range(1, n):
        if cnt_2(a[i]) != cnt:
            return 0

    l = reduce(lcm, a, a[0]) * 2 ** cnt
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2

    res = 1
    while True:
        if a[0] % 2 == 0:
            for i in range(n):
                if a[i] % 2 == 1:
                    return 0
                a[i] //= 2
            res *= 2
        else:
            break

    l = reduce(lcm, a, a[0]) * res
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2

    oe = a[0] & 1
    if oe == 1:
        for i in range(n):
            if a[i] & 1 != 1:
                return 0
    else:
        ai = a[0]
        for i in range(n):
            if a[i] != ai:
                return 0

    l = reduce(lcm, a, a[0])
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2

    oe = a[0] & 1
    if oe == 1:
        for i in range(n):
            if a[i] & 1 != 1:
                return 0
    else:
        ai = a[0]
        for i in range(n):
            if a[i] != ai:
                return 0

    l = reduce(lcm, a)
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from fractions import gcd
from functools import reduce
def lcm(a,b):
    return a//gcd(a,b)*b

def resolve():
    n,m=map(int,input().split())
    A=list(map(lambda x:int(x)//2,input().split()))
    l=reduce(lcm,A)
    print((m+l)//(2*l))
resolve()

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2
    oe = a[0] & 1
    for i in range(n):
        if a[i] & 1 != oe:
            return 0
            
    l = reduce(lcm, a)
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2
    l = reduce(lcm, a)
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

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

n, m, *a = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        a[i] //= 2
    l = reduce(lcm, a)

    if not l % 2:
        return 0
    
    return m // l - m // (l * 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)

n,m=map(int,input().split())
ar=set(map(int,input().split()))
c=0
times=0
for x in ar:
    if times==0:
        times+=1
        c=x//2
        continue
    c=(c*(x//2))//gcd(c,(x//2))
ans=(m+c)//(2*c)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import numpy as np
x,y = map(int,input().split())
A = list(map(int,input().split()))
B = [0]*len(A)
for i in range(x):
    B[i] = A[i]//2

def is_even(num):
    return num % 2 == 0

for j in range(x):
    if is_even(B[j])==True:
        print(0)
        sys.exit()
def lcm(h, g):
    return (h * g) // fractions.gcd(h, g)
for i in range(1,len(B)):
    B[i]=lcm(B[i-1], B[i])

if int(B[x-1])>y:
    print(0)
else:
  print((y-int(B[x-1]))//(2*int(B[x-1]))+1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import numpy as np
x,y = map(int,input().split())
A = list(map(int,input().split()))
B = [0]*len(A)
for i in range(x):
    B[i] = A[i]//2

def is_even(num):
    return num % 2 == 0

for j in range(x):
    if is_even(B[j])==True:
        print(0)
        sys.exit()
def lcm(h, g):
    return (h * g) // fractions.gcd(h, g)
for i in range(1,len(B)):
    B[i]=lcm(B[i-1], B[i])

if int(B[x-1])>x:
    print(0)
else:
  print((y-int(B[x-1]))//(2*int(B[x-1]))+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

N, M = MAP()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
    if l > M*2:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ceil(ans, 2))

Submission status: Wrong Answer

Solution code:

import sys
import itertools
from functools import reduce
#import math
import fractions
 
def calc_double(n):
    return n//2
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=list(map(calc_double,A))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """
 
    a=lcm_list(AA)
    #a=a//2
    """
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break
    """
    odd=M//a
    count=(odd+1)//2
 
    print(count)
 
    
 
from io import StringIO
import unittest
 
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)
 
if __name__ == "__main__":
    #unittest.main()
    resolve()