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 math
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x

n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
count = 0
mini = lcm(a)
print((m * 2 - mini) // (mini * 2) + 1) if mini % 4 != 0 else print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a //= 2
    res *= a//gcd(res,a)
    if res > M:
        #flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    #print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a //= 2
    res *= a//gcd(res,a)
    if res > M:
        #flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    #print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

res = A[0]//2
for i in range(1,N):
    res = res*A[i]//2//gcd(res,A[i]//2)
    #print(res)

if M < res//2:
    ans = 0
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

res = A[0]//2
for i in range(1,N):
    res = res*A[i]//2//gcd(res,A[i]//2)
    #print(res)

if M < res//2:
    ans = 0
else:
    #ans = (M - res(A)//2)//res + 1
    ans = (M-1)//res//2 + 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 13:52:28 2020

@author: liang
"""

from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

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

if M < max(A)//2:
    ans = 0
else:
    ans = (M - max(A)//2)//res + 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 13:52:28 2020

@author: liang
"""

from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

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

if M < max(A)//2:
    ans = 0
else:
    ans = (M - max(A)//2)//res + 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 13:52:28 2020

@author: liang
"""

from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

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

if M < res//2:
    ans = 0
else:
    ans = (M - res//2)//res + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np
import math

N, M = map(int, input().split())
a2 = list(map(int, input().split()))
a = []
for i in a2:
    a.append(i//2)

lcm = a[0]

for i in a:
    lcm *= i // math.gcd(lcm, i)

hasAns = True
for i in a:
    if (lcm // i) % 2 ==0:
        hasAns = False
        break

ans = 0

if hasAns:
    ans = (M // lcm) // 2 + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np
import math

N, M = map(int, input().split())
a2 = list(map(int, input().split()))
a = []
for i in a2:
    a.append(i//2)

lcm = 1

for i in a:
    lcm *= i // math.gcd(lcm, i)

hasAns = True
for i in a:
    if (lcm // i) % 2 ==0:
        hasAns = False
        break

ans = 0

if hasAns:
    ans = (M // lcm) // 2 + 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

#素数リスト
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    for i, j in enumerate(tmp):
        if j:
            res.append(i)

    return res
prime_number = prime_list()

def prime_fact(n):
    primes = []
    for i in prime_number:
        tmp = 0
        while n % i == 0:
            tmp += 1
            n //= i
        if tmp != 0:
            primes.append([i, tmp])
        if i * i > n:
            break

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

two = []
for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        if k == 2:
            if len(two) != 0 and two[-1] != v:
                print(0)
                exit()
            two.append(v)
        so[k] = max(so[k], v)

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

#素数リスト
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    for i, j in enumerate(tmp):
        if j:
            res.append(i)

    return res
prime_number = prime_list()

def prime_fact(n):
    primes = []
    for i in prime_number:
        tmp = 0
        while n % i == 0:
            tmp += 1
            n //= i
        if tmp != 0:
            primes.append([i, tmp])
        if i * i > n:
            break

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

two = []
for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        if k == 2:
            two.append(v)
        so[k] = max(so[k], v)

for i in range(1, len(two)):
    if two[i] != two[i-1]:
        print(0)
        exit()

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

#素数リスト
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    for i, j in enumerate(tmp):
        if j:
            res.append(i)

    return res
prime_number = prime_list()

def prime_fact(n):
    primes = []
    for i in prime_number:
        tmp = 0
        while n % i == 0:
            tmp += 1
            n //= i
        if tmp != 0:
            primes.append([i, tmp])
        if i * i > n:
            break

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        so[k] = max(so[k], v)

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

#素数リスト
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    for i, j in enumerate(tmp):
        if j:
            res.append(i)

    return res
prime_number = prime_list()
def prime_fact(n):
    primes = []
    for i in prime_number:
        tmp = 0
        while n % i == 0:
            tmp += 1
            n //= i
        if tmp != 0:
            primes.append([i, tmp])
        if n < i:
            break

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        so[k] = max(so[k], v)

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def prime_fact(n):
    primes = []
    i = 2
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n //= i
            cnt += 1
        if cnt:
            primes.append([i, cnt])
        i += 1

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        so[k] = max(so[k], v)

# tmp = 1
# for i, j in so.items():
#     tmp *= i ** j
#     if tmp > m:
#         print(0)
#         exit()
# 
# tmp //= 2
# # print(tmp)
# ans = m // tmp
# 
# if ans % 2 == 0:
#     ans //= 2
# else:
#     ans //=2
#     ans += 1
# 
# print(ans)
#

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def prime_fact(n):
    primes = []
    i = 2
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n //= i
            cnt += 1
        if cnt:
            primes.append([i, cnt])
        i += 1

    if n != 1:
        primes.append([n, 1])
    return primes

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

so = defaultdict(int)

for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        so[k] = max(so[k], v)

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np

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

a2 = [int(i/2) for i in a]
a2.sort()

bigList = [a2[len(a2)-1]*i for i in range(int(M/a2[len(a2)-1]))]
ans = len(bigList)

for i in bigList:
    for eachA in a2:
        if (i/eachA) % 2 != 1:
            ans-=1
            break

print(ans)

Submission status: Wrong Answer

Solution code:
# 97

import numpy as np

N, M = map(int, input().split())
A_L = [int(x)//2 for x in input().split()]

a_array = np.array(A_L)
lcm = np.lcm.reduce(a_array)

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

Submission status: Wrong Answer

Solution code:
# 97

import numpy as np

N, M = map(int, input().split())
A_L = [int(x)//2 for x in input().split()]

a_array = np.array(A_L)
lcm = np.lcm.reduce(a_array)

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

Submission status: Wrong Answer

Solution code:
import math

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

if n==1:
  a1=a[0]//2
  ans_m=m//a1
  if ans_m==0:
    print(0)
  else:
    print((ans_m-1)//2+1)
  
else:
  x=a[0]
  ch=0
  ch1=0
  while x%2==0:
    x=x//2
    ch+=1
  dob=2**ch
  for i in a:
    if i%dob==0 and i%(dob*2)!=1:
      ch1+=1
  if ch1!=n:
    print(0)
  else:
    ans=a[0]//2
    for j in range(1,n):
      ans=(ans*(a[j]//2))//math.gcd(ans,a[j]//2)
    ans_m=m//ans
    if ans_m==0:
      print(0)
    else:
      print((ans_m-1)//2+1)

Submission status: Wrong Answer

Solution code:
import sys
import functools
from math import gcd


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


def lcm(x):
    return functools.reduce(lcm2, x)


def resolve(in_):
    N, M = map(int, next(in_).split())
    A = tuple(map(lambda x: int(x) // 2, next(in_).split()))

    l = lcm(A)
    l2 = l + l

    answer = sum(1 for i in range(l, M + 1, l2))
    # x = list(range(l, M + 1, l2))

    return answer


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

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


G = A[0]/2
for a in A[1:]:
    G *= (a/2)/gcd(G,a//2)

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

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


G = A[0]/2
for a in A[1:]:
    print(G)
    G *= (a/2)/gcd(G,a//2)

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

Submission status: Wrong Answer

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

def gcd(x, y):
  c = 0
  if x < y:
    temp = y
    x = y    
    y = temp    
  while (y > 0):
    c = int(x % y)
    x = int(y)
    y = int(c)
  return int(x)

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

def multi_lcm(arr):
  if len(arr) == 1:
    return arr[0]
  temp = 1
  for i in arr:
    temp = int(lcm(i, temp))
  return temp

for i, var in enumerate(a):
  a[i] = int(var/2)

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = int(temp2 / 2)
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = int(temp2 / 2)
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()

a_lcm = int(multi_lcm(a))
inc = 2 * a_lcm

if a_lcm > M:
  print("0")
  exit()
else:
  print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)

def gcd(x, y):
  c = 0
  if x < y:
    x, y = x, y
  while (y > 0):
    c = x%y
    x = y
    y = c
  return x

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

def multi_lcm(arr):
  temp = 1
  for i in arr:
    temp = lcm(i, temp)
  return temp

if len(a) < 2:
  if M - (a[0] / 2 ) < 0:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // a[0] ))
    exit()

for i, var in enumerate(a):
  a[i] = int(var/2)

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
a_lcm = multi_lcm(a)
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  if M - (a[0] / 2 ) < 0:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // (2 * a[0]) ))
    exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, input().split()))


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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  if M - (a[0] / 2 ) < 0:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // a[0] ))
    exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  if M - (a[0] / 2 ) < 0:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // a[0] ))
    exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  if M - (a[0] / 2 ) >= 0:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // a[0] ))
    exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  if a[0] > M:
    print("0")
    exit()
  else:
    print(1 + int((M - (a[0] / 2)) // a[0] ))
    exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_lcm(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  print(1 + int((M - (a[0] / 2)) // a[0] ))
  exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
inc = 2 * a_lcm

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
N = len(a)

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

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

def multi_gcd(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = gcd(i, temp)
  return temp

def multi_lcm(arr):
  temp = 1
  for i in arr:
    temp *= i
  return temp / (multi_gcd(copy.copy(arr)) ** (len(arr) - 1))

def multi_lcm2(arr):
  temp = arr.pop(0)
  for i in arr:
    temp = lcm(i, temp)
  return temp

if N == 1:
  print(1 + int((M - (a[0] / 2)) // a[0] ))
  exit()

temp = 0
temp2 = a[0]
temp3 = 0
while temp2 % 2 == 0:
  temp2 = temp2 / 2
  temp += 1
for i in a:
  temp2 = i
  temp3 = 0
  while temp2 % 2 == 0:
    temp2 = temp2 / 2
    temp3 += 1
  if temp != temp3:
    print("0")
    exit()
    
  
a_lcm = multi_lcm2([i/2 for i in a])
inc = multi_lcm2(copy.copy(a))

if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Wrong Answer

Solution code:
from math import gcd
import sys

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

lcm = 1
for a in A:
    gcd_ = gcd(lcm, a//2)
    lcm = lcm * (a // 2 // gcd_)
for a in A:
    if lcm // (a // 2) % 2 == 1:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

Solution code:
from math import gcd
import sys

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

lcm = 1
for a in A:
    gcd_ = gcd(lcm, a//2)
    lcm = lcm * (a // 2 // gcd_)
    if lcm > M:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

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

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

LCM=lcm(*A)
for a in A:
  if a%2==0:
    print(0)
    break
else:
  print((M//LCM+1)//2)
  
#print((M//lcm(*A)+1)//2)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

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

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

ans=M//lcm(*A)
if ans%2==0:
  print(ans//2)
else:
  print(ans//2+1)
#print((M//lcm(*A)+1)//2)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

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

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

print(((M//lcm(*A))+1)//2)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
  
print((M//lcm(*A)+1)//2)

Submission status: Wrong Answer

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

import math
gcd = A[0]
for i in range(1,len(A)):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])
gcd //= 2
if gcd%2 == 0:
    print(0)
else:
    if gcd > M:
        print(0)
    else:
        print((M-gcd)//(2*gcd) + 1)

Submission status: Wrong Answer

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

import math
gcd = A[0]
for i in range(1,len(A)):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])
gcd //= 2
if gcd > M:
    print(0)
else:
    print((M-gcd)//(2*gcd) + 1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f


def lcm(A,M,f=0):
    
    cur=A[0]
    for a in A[1:]:
        d=a//math.gcd(a,cur)
        if f:
            if d%2==0:
                return -1
        cur=cur*d
        if cur>M:
            return -1

    return cur

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    m1=lcm(tuple(a//2 for a in A),M,1)
    if m1==-1:
        print(0)
        return
    m2=lcm(A,M)
    if m2==-1:
        print(1)
        return
    ans=1+(M-m1)//m2
    print(ans)


if __name__ == "__main__":
    main()