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:
'''
https://atcoder.jp/contests/abc150/tasks/abc150_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    if n == 1:
        if m >= a[0]:
            print((m-a[0]) // a[0] + 1)
        else:
            print(0)
        exit()

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    lcm = lcm_group(a)
    semi_lcm = lcm // 2
    if m >= semi_lcm:
        print((m-semi_lcm)//lcm + 1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
print (0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

if len(set([i&-i for i in a])) != 1:
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = x*(a[i]/2//gcd(x,a[i]/2))

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))
set(a)

fdigit = 0
while True:
	c = 1 << fdigit
	if a[0] & c != 0:
		break
	fdigit += 1

alcm = 1
for i in range(N):
	digit = 0
	while True:
		c = 1 << digit
		if a[0] & c != 0:
			break
		digit += 1
	if digit != fdigit:
		print(0)
		sys.exit(0)

	alcm = (alcm * a[i]) // fractions.gcd(alcm, a[i])

print(math.ceil((M // alcm) / 2))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

N,M = LI()
A = LI_2()

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

print (math.ceil((M//lcm) / 2))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

N,M = LI()
A = LI_2()

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

print (math.ceil((M//lcm) / 2))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from functools import reduce
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

#lcm = lambda a : reduce(lambda x, y : x * y // gcd(x,y), a)
N,M = LI()
A = LI_2()

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

print (math.ceil((M//lcm) / 2))

Submission status: Wrong Answer

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

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

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

def count2(i):
  ret = 0
  while 1:
    if i%2 == 0:
      ret += 1
      i = i/2
    else:
      return ret

if len(set([count2(i) for i in a])) != 1:
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = lcm(x, a[i]/2)

  print(int(((M//x)+1)//2))

Submission status: Wrong Answer

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

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

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

  
if len(set([i&-i for i in a])) != 1:
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = lcm(x, a[i]/2)

  print(int(((M//x)+1)//2))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from functools import reduce
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

lcm = lambda a : reduce(lambda x, y : x * y // gcd(x,y), a)
N,M = LI()
A = LI_2()
c = lcm(A)
for i in A:
    if (c // i) % 2 == 0:
        print (0)
        exit (0)
print (math.ceil((M//c) / 2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))
set(a)

c = 1
x = max(a)
while c != 0:
	if x & c != 0:
		dcount = (1 << (len(bin(c)) - 3)) - 1
		break
	c <<= 1

alcm = 1
for i in range(N):
	if a[i] & dcount != 0:
		print(0)
		sys.exit(0)
	alcm = (alcm * a[i]) // fractions.gcd(alcm, a[i])

print(math.ceil((M // alcm) / 2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))

c = 1
while c != 0:
	if a[0] & c != 0:
		dcount = (1 << (len(bin(c)) - 3)) - 1
		break
	c <<= 1

alcm = 1
for i in range(N):
	if a[i] & dcount != 0:
		print(0)
		sys.exit(0)
	alcm = (alcm * a[i]) // fractions.gcd(alcm, a[i])

print(math.ceil((M // alcm) / 2))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from functools import reduce
from fractions import gcd
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

lcm = lambda a : reduce(lambda x, y : x * y // gcd(x,y), a)
N,M = LI()
A = LI_2()
c = lcm(A)
for i in A:
    if (c // i) % 2 == 0:
        print (0)
        exit (0)
print (round((M+c)/(c*2)))

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy
from functools import reduce
from fractions import gcd
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

lcm = lambda a : reduce(lambda x, y : x * y // gcd(x,y), a)
N,M = LI()
A = LI_2()
c = lcm(A)
for i in A:
    if (c // i) % 2 == 0:
        print (0)
        exit (0)
print (round((M+c//2)/(c*2)))

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))

alcm = 1
for i in range(N):
	if a[i] & 1 == 0:
		print(0)
		sys.exit(0)
	alcm = (alcm * a[i]) // fractions.gcd(alcm, a[i])

print(math.ceil((M // alcm) / 2))

Submission status: Wrong Answer

Solution code:
import math
import fractions

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))

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

print(math.ceil((M // alcm) / 2))

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

  
if len(set([i&-i for i in a])) != 1:
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = x * a[i]/2 // fractions.gcd(x, a[i]/2)

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

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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

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

  
if len(set([i&-i for i in a])) != 1:
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = x * a[i]/2 // fractions.gcd(x, a[i]/2)

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

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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

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

  
a_ = [i&-i for i in a]

if not all(i == a_[0] for i in a_):
  print(0)
else:
  x = a[0]/2
  for i in range(1, len(a)):
      x = x * a[i]/2 // fractions.gcd(x, a[i]/2)

  print(math.floor((math.floor(M/x)+1)/2))

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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

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

  
a_ = [i&-i for i in a]

if not all(i == a_[0] for i in a_):
  print(0)
else:
  k = a_[0]
  M = math.floor(M/(k/2))
  a  = [i/k for i in a]
  
  x = a[0]
  for i in range(1, len(a)):
      x = x * a[i] // fractions.gcd(x, a[i])

  print(math.floor((math.floor(M/x)+1)/2))

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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

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

  
a_ = [i&-i for i in a]

if not all(i == a_[0] for i in a_):
  print(0)
else:
  k = a_[0]
  M = math.floor(M/(k-1))
  a  = [i/k for i in a]
  
  x = a[0]
  for i in range(1, len(a)):
      x = x * a[i] // fractions.gcd(x, a[i])
      
  print(math.floor((math.floor(M/x)+1)/2))

Submission status: Wrong Answer

Solution code:
import math

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

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

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

  
a_ = [i&-i for i in a]

if not all(i == a_[0] for i in a_):
  print(0)
else:
  k = a_[0]
  M = math.floor(M/(k-1))
  a  = [i/k for i in a]
  x = 1
  for i in a:
    x = lcm(x,i)
  print(math.floor((math.floor(M/x)+1)/2))

Submission status: Wrong Answer

Solution code:
import math

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

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

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

ans = 0
flag = 1
while flag:
  a = [i/2 for i in a]
  if sum([i%2 for i in a]) == 0:
    M = M/2
    continue
  elif sum([i%2 for i in a]) == N:
    x = 1
    for i in a:
      x = lcm(x,i)
    print(int(math.floor((M/x)+1)/2))
    flag = 0
  else:
    print(0)
    flag = 0

Submission status: Wrong Answer

Solution code:
import math

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

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

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

ans = 0
flag = 1
while flag:
  a = [i/2 for i in a]
  if sum([i%2 for i in a]) == 0:
    M = M/2
    continue
  elif sum([i%2 for i in a]) == N:
    x = 1
    for i in a:
      x = lcm(x,i)
    print(math.floor((M/x)+1)/2)
    flag = 0
  else:
    print(0)
    flag = 0

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict

# nを素因数分解
# 各素因数を数え上げる場合はcounterを使うとよい
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

num_2s = set()
d = defaultdict(int)
for a in A:
    c = Counter(prime_factorize(a))
    if 2 in c.keys():
        num_2s.add(c[2])
    for k, v in c.items():
        d[k] = max(d[k], v)
    
if len(num_2s) > 1 or len(num_2s) == 0:
    print(0)
else:
    num_2 = list(num_2s)[0]
    koubaisu = 1
    for k, v in d.items():
        if k != 2:
            koubaisu *= k ** v
    print((K + koubaisu * 2 ** num_2) // (2 ** num_2 * koubaisu))

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict

# nを素因数分解
# 各素因数を数え上げる場合はcounterを使うとよい
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

num_2s = set()
d = defaultdict(int)
for a in A:
    c = Counter(prime_factorize(a))
    if 2 in c.keys():
        num_2s.add(c[2])
    for k, v in c.items():
        d[k] = max(d[k], v)
    
if len(num_2s) > 1:
    print(0)
else:
    koubaisu = 1
    for k, v in d.items():
        if k != 2:
            koubaisu *= k ** v
    print(K // koubaisu - (K // (2 * koubaisu)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

f=0
f2=1
for item in A:
    if item%2==1 or item%4==0:
        print(0)
        exit()
    else:
        f=fractions.gcd(f2,item)
        f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from functools import reduce

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
    
def lcm_base(x, y):
    return x*y//gcd(x, y)

def lcm_list(list):
    return reduce(lcm_base, list)

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [x//2 for x in a]
T = lcm_list(b)
print ((M//T+1)//2)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def get2(num):
    cnt=0
    while num %2!=0:
        cnt+=1
        num//=2
    return cnt

div2=get2(a[0])
for i in range(len(a)):
    if div2 != get2(a[i]):
        print(0)
        exit()

num = lcm(a)
thr = m - num//2

if thr < 0:
    print(0)
else:
    print(thr//num + 1)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

aset=set(a)
a=list(aset)

if len(a) != 1:
    for i in range(len(a)):
        tmp = a[i]//2
        if tmp%2==0:
            print(0)
            exit()

num = lcm(a)
thr = m - num//2

if thr < 0:
    print(0)
else:
    print(thr//num + 1)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

if len(a) != 1:
    for i in range(len(a)):
        tmp = a[i]//2
        if tmp%2==0:
            print(0)
            exit()

num = lcm(a)
thr = m - num//2

if thr < 0:
    print(0)
else:
    print(thr//num + 1)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


for i in range(len(a)):
    tmp = a[i]//2
    if tmp%2==0:
        print(0)
        exit()

num = lcm(a)
thr = m - num//2

if thr < 0:
    print(0)
else:
    print(thr//num + 1)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm(a)
thr = m - num//2

if thr < 0:
    print(0)
else:
    print(thr//num + 1)

Submission status: Wrong Answer

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

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm(a)
thr = m - num//2

if thr <= 0:
    print(0)
else:
    print(-(-thr//num))

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]
for i in range(1,n):
  lcm*=A[i]//gcd(lcm,A[i])
print((m//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    for j in a:
        if j % 2 != 0:
            print("0")

    a = [i/2 for i in a]
    l = lcm_list(a)

    i = l / 2

    if m < l:
        print("0")
    else:
        print(int(((m - l) // (2*l)) + 1))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i)//2 for i in A]
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)

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


L = lcm_list(B)
print((M-L)//(2*L)+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,M = MAP()
    a = LI()

    b = [0]*N

    for i in range(N):
        aa = a[i]
        cnt = 0
        while aa%2==0:
            aa //= 2
            cnt +=1
        b[i] = cnt
    
    if b.count(b[0]) != N:
        print(0)
        return
    
    # 2で割れる回数が同じ
    import fractions
    from functools import reduce
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    def lcm_list(numbers):
        return reduce(lcm, numbers)

    LCM = lcm_list(a)
    c = M//LCM
    if c&1:
        c += 1
    
    print(c//2)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,M = MAP()
    a = LI()

    for i in range(N):
        a[i] = a[i]//2
    
    if not all([aa&1 for aa in a]) and not all([aa%2==0 for aa in a]): #全部奇数か全部偶数以外は答え０
        print(0)
        return

    import fractions
    from functools import reduce
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    def gcd_list(numbers):
        return reduce(lcm, numbers)

    GCD = gcd_list(a)
    b = M//GCD
    if b&1:
        b += 1
    
    print(b//2)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)  # 数列に対しての最小公倍数


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [x // 2 for x in a]
c = 0
while a[0] % (2 ** (c + 1)) == 0:
    c += 1

for x in a:
    if x % c != 0 or x % (c * 2) == 0:
        print(0)
        exit()

lc = lcm(*b)

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
table=set()
def prime_decomposition(n):
  i = 2
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i%2!=0:
          table.add(int(i))
    i += 1
  if n > 1 and n%2!=0:
        table.add(int(n))

for i in range(len(a)):
    prime_decomposition(a[i])

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

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

tmp=list(table)
count=1
for i in range(len(tmp)):
    count=lcm(count,tmp[i])
if count>M:
    print(0)
    exit()
vv=count*2
ans=1+(M-count)//vv
print(ans)

Submission status: Wrong Answer

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

table=set()
def prime_decomposition(n):
  i = 2
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i%2!=0:
          table.add(int(i))
    i += 1
  if n > 1 and n%2!=0:
        table.add(int(n))

for i in range(len(a)):
    prime_decomposition(a[i])

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

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

tmp=list(table)
count=1
for i in range(len(tmp)):
    count=lcm(count,tmp[i])

gh=M//(count*2)
if M%(count*2)==0:
    ans=gh
else:
    ans=gh
    leng=M-gh*(count*2)
    if leng>=count:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())))

cnt = 0
while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		cnt -= 1
		break
	else:
		cnt += 1
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd
M = math.floor(M/(2**cnt))

ans = 1 + (M-lcm)//(2*lcm)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())))

cnt = 0
while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		cnt -= 1
		break
	else:
		cnt += 1
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd
lcm *= 2 ** cnt

#ans = 1 + (M - lcm) // (2 * lcm)

#print(ans)
maximum = A.max()//2
if lcm < maximum:
	ans = 1 + (M-maximum)//(2*lcm)
else:
	ans = 1 + (M-lcm) // (2*lcm)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())))

cnt = 0
while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		cnt -= 1
		break
	else:
		cnt += 1
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd
lcm *= 2 ** cnt

ans = 1 + (M - lcm) // (2 * lcm)

print(ans)
#maximum = A.max()//2
#if lcm < maximum:
#	ans = 1 + (M-maximum)//(2*lcm)
#else:
#	ans = 1 + (M-lcm) // (2*lcm)

#print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())))

while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		break
	else:
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd

maximum = A.max()//2
if lcm < maximum:
	ans = 1 + (M-maximum)//(2*lcm)
else:
	ans = 1 + (M-lcm) // (2*lcm)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())))

while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		break
	else:
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd

ans = 1 + (M-lcm) // (2*lcm)

print(ans)

Submission status: Wrong Answer

Solution code:
import functools

N,M = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*N

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

def multiple(a, b):
    return a*b // euclid(a, b)

def lcm(nums):
        return functools.reduce(multiple, nums)

def count_two(n):
    c = 0
    while n%2 ==0:
        c += 1
        n //= 2
    return c

l = [0]*N
for i in range(N):
    l[i] = count_two(a[i])

if len(set(l)) != 1:
    print(0)
else:
    p_2 = l[0] #2で何回割れるか
    for i in range(N):
        b[i] = a[i] // (2**p_2)
    
    X = lcm(b)*(2**(p_2-1))
    print(X)
    nax = M // X

    print((nax+1)//2)

Submission status: Wrong Answer

Solution code:
import functools

N,M = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*N

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

def multiple(a, b):
    return a*b // euclid(a, b)

def lcm(nums):
        return functools.reduce(multiple, nums)

def count_two(n):
    c = 0
    while n%2 ==0:
        c += 1
        n //= 2
    return c

l = [0]*N
for i in range(N):
    l[i] = count_two(a[i])

if len(set(l)) != 1:
    print(0)
else:
    p_2 = l[0] #2で何回割れるか
    for i in range(N):
        b[i] = a[i] // (2**p_2)
    
    X = lcm(b)
    nax = M // X

    print(nax//2+1)

Submission status: Wrong Answer

Solution code:
import math
import bisect
import heapq
from fractions import gcd
from collections import deque

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

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


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


def scm(a):
    for i in range(n):
        if a[i] % 2 == 1:
            return 0
    l = 1
    for i in range(n):
        a[i] = a[i] // 2
        l = lcm(l,a[i])

    count = 0
    lc = l
    if not 1 <= l <= m:
        return 0

    for i in range(l, m+1, 2*lc):
        count += 1

    return count

print(scm(a))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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

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

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

def func(x):
    return x // 2

def main():
    N, M = map(int, input().split())
    A = list(map(func, map(int, input().split())))

    l = lcm_list(A)

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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

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

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

def func(x):
    return x // 2

def main():
    N, M = map(int, input().split())
    A = list(map(func, map(int, input().split())))

    l = lcm_list(A)
    if M < l:
        print(0)
        exit()

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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

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

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

def func(x):
    return x // 2

def main():
    N, M = map(int, input().split())
    A = list(map(func, map(int, input().split())))

    l = lcm_list(A)
    if M < l:
        print(0)
        exit()

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import fractions
bbn=1000000007
	
#+++++

def gcd(a,b):
	return fractions.gcd(a,b)
	
def lcm(a,b):
	return (a*b)//gcd(a,b)
		
def main():
	n, m = map(int, input().split())
	al=list(map(int, input().split()))
	ii=al[0]//2
	ll=ii
	nn=al[0]
	for v in al[1:]:
		ll=lcm(ll,v//2)
		nn=lcm(nn,v)
	
	if ll%2==0:
		return 0
		
	ret= (max(0, (m - ll))//nn)+(min(1,m//ll))
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
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 nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()

ap = [0 for i in range(N)]
for i in range(N):
    co = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        co += 1
    ap[i] = co

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

po = lcm_list(a)

p = -(-(M // po) // 2)

print(p)