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: Runtime Error

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 = int(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: Runtime Error

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 = int(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 = int(multi_lcm(a))
inc = 2 * a_lcm

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

Submission status: Runtime Error

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 = int(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: Runtime Error

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) / int(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: Runtime Error

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
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) / int(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: Runtime Error

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
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) / int(gcd(a, b))

def multi_lcm(arr):
  temp = 1
  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([int(i/2) for i in a])
inc = 2 * a_lcm

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

Submission status: Runtime Error

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(input().split())))
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) / int(gcd(a, b))

def multi_lcm(arr):
  temp = 1
  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 = 2 * a_lcm

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

Submission status: Runtime Error

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) / int(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 = 1
  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 = 2 * a_lcm

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

Submission status: Runtime Error

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) / int(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 = 2 * a_lcm

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

Submission status: Runtime Error

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 int(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 = 2 * a_lcm

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

Submission status: Runtime Error

Solution code:
import copy
N, M = 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: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))

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

Submission status: Runtime Error

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

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

a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))

if a_lcm > M:
  print(0)
  exit()
print(1 + int(M / (2 * a_lcm)))

Submission status: Runtime Error

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

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

a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))

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

Submission status: Runtime Error

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(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_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))

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

a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Runtime Error

Solution code:
import copy
N, M = map(int, input().split())
a = list(map(int, set(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_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))

a_lcm = multi_lcm([i/2 for i in a])
inc = multi_lcm(copy.copy(a))
if a_lcm > M:
  print(0)
  exit()
print(1 + int((M - a_lcm) // inc))

Submission status: Runtime Error

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


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import numpy as np
a = np.array(a)
lcm = np.lcm.reduce(a)
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)

Submission status: Runtime Error

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


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

baisu = []

a.sort()



import math
lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // math.gcd(lcm, a[k])
lcm = np.lcm(a)
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd, ceil


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


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

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

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

ok = True
for aa in a:
    if (lcm_v//aa) % 2 != 1:
        ok = False
        break

if ok:
    ans = ((m//lcm_v)+1)//2
print(ans)

Submission status: Runtime Error

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

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

power=[0]*n
for i in range(n):
  while a[i]%2==0:
    a[i]//=2
    power[i]+=1
    
if power.count(power[0])==n:
  x=1
  for i in range(n):
    x=lcm(x,a[i]//2)

  print((m+x)//(2*x))
else:
  print(0)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
from decimal import *
import numpy as np

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

aa = set(a)
aList = sorted(list(aa))

aMax = aList[-1]


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def lcm(lis):
    tar = 1
    for i in lis:
        tar *= i

    return Decimal(tar / gcd(*lis))


'''
#最小公倍数に対して、ab両方の掛け数が奇数なら、
lcm/2はX.5になる。
'''
# num = m // aMax - 1  # 5-1 =4


aMin = lcm(aList)
# > 30
# print(min)
# print(type(aList))
aArr = np.array(aList)
aArr = aMin / aArr
# print(aArr)
mod = np.where(aArr % 2 == 1)
# print(mod[0][0])
#

if (len(aList) == len(mod[0])):
    tar = m // (aMin / 2)
    ans = tar // 2 + tar % 2
    print(ans)

else:
    print('0')

Submission status: Runtime Error

Solution code:
import math
def lcm(a, b):
    g = math.gcd(a, b)
    return a * b // g

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
    div *= 2
    a0 //= 2

for i in range(1, N):
    a = A[i] % div
    b = A[i] // div
    if (b % 2 == 0) or (a != 0):
        print(0)
        exit()

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

if N > 1:
    lcm = lcm(A[0], A[1])
    for i in range(2, N):
        lcm = lcm(lcm, A[i])

if N == 1:
    lcm = A[0]

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

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
for i in range(N):
    A[i] //= 2

for i in range(N):
    if N > 1: 
        gcd = math.gcd(A[0], A[1])
        for i in range(2, N):
            gcd = math.gcd(gcd, A[i])

lcm = gcd
for i in range(N):
    lcm *= A[i] // gcd

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


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


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


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


def main():
    n, m = map(int, readline().split())
    a = np.array(input().split(), np.int64)
    a //= 2
    b = np.copy(a)
    while True:
        c = b % 2
        if c.sum() == 0:
            b //= 2
        elif c.sum() == n:
            break
        else:
            print(0)
            sys.exit()
    d = lcm_list(a)
    if d > 10 ** 9:
        ans = 0
    else:
        ans = (m // d) - (m // (d + d))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))

    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    if lcm == 0:
        print('0')
        return
    first = lcm * 0.5

    ans_exists = True
    for i in range(N):
        if first % A[i] == 0:
            ans_exists = False

    if ans_exists:
        ans = int((M-first) // lcm + 1)
        print(ans)
    else:
        print('0')

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))

    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    first = lcm * 0.5

    ans_exists = True
    for i in range(N):
        if first % A[i] == 0:
            ans_exists = False

    if ans_exists:
        ans = int((M-first) // lcm + 1)
        print(ans)
    else:
        print('0')

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))
    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    first = lcm * 0.5
    ans = int((M-first)//lcm + 1)
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break

if flg:
  min_x = int(lcm(A)*0.5)
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = int(lcm(A)*0.5)
ans = m//min_x - m//(2*min_x)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = lcm(A)*0.5
temp = m//min_x

if min_x%2==0:
  print(0)
elif temp%2==0:
  print(int(temp//2))
else:
  print(int(temp//2+1))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = lcm(A)*0.5
temp = m//min_x

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

Submission status: Runtime Error

Solution code:
from collections import deque,defaultdict
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]
for i in range(1,n):
    tmp = lcm(tmp,A[i])
#tmpの２分の１と1.5倍が何個入るかに帰着
#m//tmp +
ans = m//tmp
if(m//(tmp)*tmp+tmp//2<=m):
    ans += 1
if(tmp//2 in A or tmp*1.5 in A):
    ans=0
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=0
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%pow2[pow_cnt]==0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow2=[2**i for i in range(32)]
tmp=half_a[0]
while tmp%pow2[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow2[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow=[2**i for i in range(30)]
tmp=half_a[0]
while tmp%pow[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow=[2**i for i in range(10)]
tmp=half_a[0]
while tmp%pow[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
import sys
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

C = gcd_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

print( (M // C + 1) // 2)

Submission status: Runtime Error

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

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # # mがlcmの半分よりも小さかったら0
        # if (a_lcm / 2) > m:
        #     print(0)
        #     exit()
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
        print(0)
        exit()
    for a in A:
        if a_lcm / 2 % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy
# from math import gcd


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

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # # mがlcmの半分よりも小さかったら0
        # if (a_lcm / 2) > m:
        #     print(0)
        #     exit()
    for a in A:
        if a_lcm / 2 % a == 0:
            print(0)
            exit()
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
        print(0)
        exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy
from math import gcd


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

def lcm(a, b):
    # return (a // gcd(a, b)) * b
    return (a * b) // gcd(a, b)
def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for i in range(n):
        a_lcm = lcm(a_lcm, A[i])
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    # for a in A:
    for i in range(n):
        # if a_lcm / 2 % A[i] == 0:
        if a_lcm // A[i] % 2 == 0: 
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy
from math import gcd


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

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

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for i in range(n):
        a_lcm = lcm(a_lcm, A[i])
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    # for a in A:
    for i in range(n):
        # if a_lcm / 2 % A[i] == 0:
        if a_lcm // A[i] % 2 == 0: 
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy
from math import gcd


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

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

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for i in range(n):
        a_lcm = lcm(a_lcm, A[i])
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    # for a in A:
    for i in range(n):
        if a_lcm / 2 % A[i] == 0:
        # if (a_lcm // a) % 2 == 0: 
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()