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

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
a[0]=int(a[0]/2)
num=a[0]
for i in range(1,N):
    a[i]=int(a[i]/2)
    num=lcm(a[i],num)
    
#print(num)
if num>M:
    print(0)
else:
    print(math.ceil(int(M/num)/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

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
a[0]=int(a[0]/2)
num=a[0]
for i in range(1,N):
    a[i]=int(a[i]/2)
    num=lcm(a[i],num)
    
#print(num)
if num>M:
    print(0)
else:
    print(math.ceil(M/(2*num)))

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

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
a[0]=int(a[0]/2)
num=a[0]
for i in range(1,N):
    a[i]=int(a[i]/2)
    num=lcm(a[i],num)
    
#print(num)
if num>M:
    print(0)
else:
    print(int((M/num)//2+1 ))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def kosuu(x):
    re = [0,0]
    while x % 2 == 0:
        x = x//2
        re[1]+=1
    re[0]=x
    return re

        
 
def main():
    n,m=map(int, input().split())
    a=list(map(int, input().split()))
    li = [kosuu(a[0])[0]]
    hantei = kosuu(a[0])[1]
    for i in a[1:]:
        hantei2 = kosuu(i)
        if hantei2[1] != hantei:
            print(0)
            break
        else:
            li.append(hantei2[0])
    else:
        lc = np.lcm.reduce(li)
        print(((m//lc)+1)//2)
            


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

mi = np.lcm.reduce(A)
M += mi/2

print(int(M//mi))

Submission status: Wrong Answer

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

mi = np.lcm.reduce(A)
if M < mi/2:
    print(0)
else:
    M -= mi/2

    print(int(M//mi + 1))

Submission status: Wrong Answer

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

mi = np.lcm.reduce(A)
M -= mi/2

print(int(M//mi + 1))

Submission status: Wrong Answer

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=-1
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%(2**pow_cnt)!=0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Wrong Answer

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%(2**pow_cnt)!=0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Wrong Answer

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)
pow2=[2**i for i in range(32)]
pow_cnt=0
while half_a[0]%pow2[pow_cnt]==0:
    pow_cnt+=1
flag=True
for ai in half_a[1:]:
    if ai%pow2[pow_cnt]==0:
        flag=False
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Submission status: Wrong Answer

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]))
half_a.sort()
half_a_flag=[]
for i in range(len(half_a)):
    for j in range(i+1,len(half_a)):
        if half_a[j]%half_a[i]==0:
            half_a_flag.append(False)
        else:
            half_a_flag.append(True)
half_a_flag.append(True)
tmp=[]
for i in range(len(half_a)):
    if half_a_flag[i]:
        tmp.append(half_a[i])
half_a=tmp
# print(half_a)
lcm=-1
for i in range(len(half_a)-1):
    if half_a_flag[i]:
        if lcm==-1:
            lcm=half_a[i]
        a,b=lcm,half_a[i+1]
        lcm=a*b//math.gcd(a,b)
if len(half_a)==1:
    lcm=half_a[0]
# print(lcm)
oddcnt,evencnt=0,0
for hi in half_a:
    if hi!=1:
        if hi%2==0:
            evencnt+=1
        else:
            oddcnt+=1
if evencnt>0 and oddcnt>0:
    print(0)
else:
    print(math.ceil(m//lcm/2))

Submission status: Wrong Answer

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)
oddcnt,evencnt=0,0
for hi in half_a:
    if hi!=1:
        if hi%2==0:
            evencnt+=1
        else:
            oddcnt+=1
if evencnt>0 and oddcnt>0:
    print(0)
else:
    print(math.ceil(m//lcm/2))

Submission status: Wrong Answer

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)
print(math.ceil(m//lcm/2))

Submission status: Wrong Answer

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)
while len(half_a)>1:
    a,b=half_a[0],half_a[1]
    tmp=[a*b//math.gcd(a,b)]
    tmp.extend(half_a[2:])
    half_a=tmp
print(math.ceil(m//half_a[0]/2))

Submission status: Wrong Answer

Solution code:

import math
from sys import stdin
input = stdin.readline


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

  pre = A[0]
#   bool_ini = A[0] % 2
#   bool_end = -1

  for i in range(1, N):
    if pre % 2 != A[i] % 2:
      print(0)
      return
#  for i in range(1, N):
#    if A[i] % 2 == 0 and A[i] != pre:
#      print(0)
#      return
#    else:
#      bool_end = A[i] % 2
#
#    pre = A[i]
#
#  if bool_ini != bool_end:
#    print(0)
#    return

  # if bool_end % 2:
  lcm = A[0]
  for i in range(1, N):
    lcm = lcm * A[i] // math.gcd(lcm, A[i])
  print((M // lcm + 1) // 2)
  return


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

Submission status: Wrong Answer

Solution code:

import math
from sys import stdin
input = stdin.readline


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

  pre = A[0]
  bool_ini = A[0] % 2
  bool_end = -1

  for i in range(1, N):
    if A[i] % 2 == 0 and A[i] != pre:
      print(0)
      return
    else:
      bool_end = A[i] % 2

    pre = A[i]

  if bool_ini != bool_end:
    print(0)
    return

  # if bool_end % 2:
  lcm = A[0]
  for i in range(1, N):
    lcm = lcm * A[i] // math.gcd(lcm, A[i])
  print((M // lcm + 1) // 2)
  return


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

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    num, m = map(int, input().split())
    data = list(map(int, input().split()))

    min_koubaisuu = data[0]

    for i in range(1, num):
        min_koubaisuu = lcm(min_koubaisuu, data[i])

    baisuu = min_koubaisuu // 2

    ans = ((m // baisuu) + 1) // 2

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(numbers):
    x = numbers[0]
    for y in numbers:
        x = lcm_base(x, y)
    return x

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
q, r = divmod(M // lc , 2)
print(q + r)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def gcd_list(numbers):
    ret = numbers[0]
    for a in numbers:
        ret = gcd(ret, a)
    return ret

def lcm(numbers):
    d = Counter(numbers)
    acc = 1
    for a in d.keys():
        acc *= a
    return acc // gcd_list(list(d.keys()))

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
for a in aaa:
    if lc % a == 0:
        print(0)
        exit()
q, r = divmod(M // lc , 2)
print(q + r)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def gcd_list(numbers):
    ret = numbers[0]
    for a in numbers:
        ret = gcd(ret, a)
    return ret

def lcm(numbers):
    d = Counter(numbers)
    acc = 1
    for a in d.keys():
        acc *= a
    return acc // gcd_list(list(d.keys()))

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
for a in aaa:
    if lc % a == 0:
        print(0)
        exit()
print(M // lc - (M // lc // 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def gcd_list(numbers):
    ret = numbers[0]
    for a in numbers:
        ret = gcd(ret, a)
    return ret

def lcm(numbers):
    d = Counter(numbers)
    acc = 1
    for a in d.keys():
        acc *= a
    return acc // gcd_list(list(d.keys()))

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
i = 0
flag = True
while flag:
    i += 1
    for a in aaa:
        if a % 2 ** i != 0:
            flag = False
            break
for a in aaa:
    if a % 2 ** i == 0:
        print(0)
        exit()
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
print(M // lc - (M // lc // 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def gcd_list(numbers):
    ret = numbers[0]
    for a in numbers:
        ret = gcd(ret, a)
    return ret

def lcm(numbers):
    d = Counter(numbers)
    acc = 1
    for a in d.keys():
        acc *= a
    return acc // gcd_list(list(d.keys()))

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
i = 0
flag = True
while flag:
    i += 1
    for a in aaa:
        if a % 2 ** i != 0:
            flag = False
            break
for a in aaa:
    if a % 2 ** i == 0:
        print(0)
        exit()
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
print(M // lc // 2 + (M // lc % 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def gcd_list(numbers):
    ret = numbers[0]
    for a in numbers:
        ret = gcd(ret, a)
    return ret

def lcm(numbers):
    d = Counter(numbers)
    acc = 1
    for a in d.keys():
        acc *= a
    return acc // gcd_list(list(d.keys()))

N, M = map(int, input().split())
aaa = list(map(int, input().split()))
cnt = 0
a = aaa[0]
while a % 2 == 0:
    a //= 2
    cnt += 1
for a in aaa:
    if a % 2 ** cnt != 0:
        print(0)
        exit()
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
print(M // lc // 2 + (M // lc % 2))

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        # # これなら72は通る
        # print(0)
        # exit()
        # if a_lcm // 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
        if a % 2 == 0:
            continue
    else:
        print(0)
        exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        # # これなら72は通る
        # print(0)
        # exit()
        # if a_lcm // 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
        if a % 2 == 0:
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        # # これなら72は通る
        print(a)
        exit()
        # if a_lcm / 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
        #    print(0)
        #    exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        print(0)
        exit()
        # if a_lcm / 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
        #     print(0)
        #     exit()
        # else:
        #     continue
    # # mがlcmの半分よりも小さかったら0
    # if (a_lcm / 2) > m:
    # # if a_lcm > m * 2:
    #     print(0)
    #     exit()
    # else:
    #     # # あとは定数倍の数調べて終わり
    #     ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    #     print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        print(0)
        exit(0)
        # if a_lcm / 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
        #     print(0)
        #     exit()
        # else:
        #     continue
    # # mがlcmの半分よりも小さかったら0
    # if (a_lcm / 2) > m:
    # # if a_lcm > m * 2:
    #     print(0)
    #     exit()
    # else:
    #     # # あとは定数倍の数調べて終わり
    #     ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    #     print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
import sys
sys.setrecursionlimit(10**7)

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 a in A:
        a_lcm = lcm(a_lcm, a)
    print(1)
    # #else:
    # #    a_lcm = a_lcm
    # # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    # #for i in A_:
    # for i in A:
    #     if (a_lcm / 2) % i == 0:
    #     # if (a_lcm / i) % 2 == 0: 
    #         print(0)
    #         exit()
    #     # else:
    #     #     continue
    # # mがlcmの半分よりも小さかったら0
    # if (a_lcm / 2) > m:
    # # if a_lcm > m * 2:
    #     print(0)
    #     exit()
    # else:
    #     # # あとは定数倍の数調べて終わり
    #     ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    #     print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
def lcm(ab):
    l=len(ab)
    ret=ab[0]
    for i in range(1,l):
        ret=ret//gcd(ab[i],ret)*ab[i]
    return ret
def count2(a):
    ret=0
    while a%2==0:
        a//=2
        ret+=1
    return 2**ret
n,m=map(int,input().split())
A=list(map(int,input().split()))
if any(i%2 for i in A):
    exit(print(0))
A=[i//2 for i in A]
#全体の最小公倍数
p=lcm(A)
c=count2(p)
#2で割り切れる回数が同じでないものがある場合
#違うじゃん
if any(i%c for i in A):
    exit(print(0))
x=m//(p//c)
#print(p//c)
if x%2==0:
    print(x//2)
else:
    print(x//2+1)

Submission status: Wrong Answer

Solution code:
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
def lcm(ab):
    l=len(ab)
    ret=ab[0]
    for i in range(1,l):
        ret=ret//gcd(ab[i],ret)*ab[i]
    return ret
def count2(a):
    ret=0
    while a%2==0:
        a//=2
        ret+=1
    return 2**ret
n,m=map(int,input().split())
A=list(map(int,input().split()))
#全体の最小公倍数
p=lcm(A)
c=count2(p)
#2で割り切れる回数が同じでないものがある場合
if any(i%c for i in A):
    exit(print(0))
x=m//(p//c)
#print(p//c)
if x%2==0:
    print(x//2)
else:
    print(x//2+1)

Submission status: Wrong Answer

Solution code:
def main():
    import math
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    e,o = 0,0
    for i in range(n):
        if a[i]%2==1:
            e = 1
        else:
            o = 1
    if e==1 and o==1:
        print(0)
        return
    for i in range(n):
        a[i] = a[i]//2
    gcd = 1
    for i in range(n):
        gcd = gcd * a[i] //math.gcd(a[i],gcd)
    ans = m//gcd
    if ans%2==0:
        print(ans//2)
    else:
        print((ans+1)//2)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if N==1:
  if A[0] > M: print(0)
  else:print((M - int(A[0]*1.5))//A[0]+1)
else:
  A=np.array(A)
  B=A//2
  
  if (B % 2).sum() not in [0, len(B)]:print(0)
  else:
    LCM1 = np.lcm.reduce(A)
    LCM2 = np.lcm.reduce(B)
    if LCM2 > M: print(0)
    else:print((M-LCM2)//LCM1 + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if N==1:
  if A[0] > M: print(0)
  else:print((M - int(A[0]*1.5))//A[0]+1)
else:
  A=np.array(A)
  B=A//2

  LCM1 = np.lcm.reduce(A)
  LCM2 = np.lcm.reduce(B)
  if LCM2 > M: print(0)
  else:print((M-LCM2)//LCM1 + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=np.array(A)
B=A//2

LCM1 = np.lcm.reduce(A)
LCM2 = np.lcm.reduce(B)
if LCM2 > M: print(0)
else:print((M-LCM2)//LCM1 + 1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
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)

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

odd=0
even=0
for i in a:
  if i%2 == 0:
    even+=1
  else:
    odd+=1
b=lcm_list(a)

if even != 0 and odd != 0:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
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)

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

odd=0
even=0
for i in a:
  if i%2 == 0:
    even+=1
  else:
    odd+=1
b=lcm_list(a)

if even != 0 & odd != 0:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
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)

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in list(set(a))]
b=lcm_list(a)
  
ans = (m-b)//(2*b) + 1
print(max(ans,0))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in list(set(a))]
b=1
no = 0
for i in a:
  if i != 1:
    no += 1
  b *= i
  
if no > 1 and no != 0:
  ans = (m-b)//(2*b) + 1
else:
  ans = (m-b)//(2*b) + 1

print(max(ans,0))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in list(set(a))]
b=1
no = 0
for i in a:
  if i != 1:
    no += 1
  b *= i
  
if no > 1 and no != 0:
  ans = m//b - 1
else:
  ans = (m-b)//(2*b) + 1

print(max(ans,0))

Submission status: Wrong Answer

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

cnt = 1
while A[0]%(2**(cnt+1)) == 0:
    cnt += 1

for i in range(n):
    if A[i]%(2**cnt) != 0 or (A[i]//(2**cnt))%2==0:
        print(0)
        exit()
    A[i]//=2**cnt

y = 1
for i in set(A):
    y *= i

print((m + y)//((2 ** cnt) * y))

Submission status: Wrong Answer

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

cnt = 1
while A[0]%(2**(cnt+1)) == 0:
    cnt += 1

for i in range(n):
    if A[i]%(2**cnt) != 0 or (A[i]//(2**cnt))%2==0:
        print(0)
        exit()
    A[i]//=2**cnt

y = 1
for i in set(A):
    y *= i

print((m + y)//(2 * y))

Submission status: Wrong Answer

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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    if lcm1//(t//2)!=0 and lcm1//(t//2)%2==0:
        lcm1=0
        lcm2=0
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)


if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)

Submission status: Wrong Answer

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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    if lcm1//(t//2)%2==0:
        lcm1=0
        lcm2=0
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)


if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)

Submission status: Wrong Answer

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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)
    if lcm1//t%2==0:
        lcm1=0
        lcm2=0
if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)

Submission status: Wrong Answer

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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)

ans1=m//lcm1
ans2=m//lcm2

print(ans1-ans2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i//2 for i in aas]
import math
N = len(a)
def n_of_twos(x):
    res = 0
    while x%(2*(res+1))==0:
        res += 1
    return res
if N>=2:
    n_of_twos_0 = n_of_twos(a[0])
    for i in range(1,N):
        if n_of_twos(a[i]) != n_of_twos_0:
            print(0)
            exit()
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
print(1 + (m//ans-1)//2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i//2 for i in aas]

import math
N = len(a)
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i//2 for i in aas]
import math
N = len(a)
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
if ans == m:
    print(1)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i//2 for i in aas]

even = False
for i in a:
    if i%2 == 0:
        if even:
            print(0)
            exit()
        else:
            even = True
import math
N = len(a)
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
if ans == m:
    print(1)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

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

even = False
for i in set(aas):
    if i/2%2 == 0:
        if even:
            print(0)
            exit()
        else:
            even = True
import math
a = [i//2 for i in aas] #
N = n
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
if ans == m:
    print(1)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
aas = list(map(int, input().split()))
import math
a = [i//2 for i in aas] #
N = n
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
if ans == m:
    print(1)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

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

even = False
for i in aas:
    if i/2%2 == 0:
        if even:
            print(0)
            exit()
        else:
            even = True
import math
a = [i//2 for i in aas] #
N = n
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
    print(0)
    exit()
if ans == m:
    print(1)
    exit()
tmp = m // ans
print(1 + (tmp-1)//2)

Submission status: Wrong Answer

Solution code:
import math

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

flg = True
times = None
for i,a in enumerate(A):
  t = 0
  while a%2==0:
    a //= 2
    t += 1

  if times is None:
    times = t
  else:
    if times != t:
      flg = False
      break
  A[i] = a

if not flg:
  print(0)
  exit()

lcm = 1
while len(A) > 1:
  a,b = A.pop(), A.pop()
  lcm = a*b // math.gcd(a,b)
  if lcm > M:
    print(0)
    exit()
  A.append(lcm)

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from copy import deepcopy
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)
Acopy = deepcopy(A)
flag = -1
for i in range(n):
  cnt = 0
  while True:
    if Acopy[i] % 2 == 1:
      break
    else:
      Acopy[i] //= 2
      cnt += 1
  if i == 0:
    flag = cnt
  else:
    if flag != cnt:
      print(0)
      break
else:
  A = [a//2 for a in A]
  lcm = lcm_list(A)
  ans = 0
  for t in range(lcm,m,2*lcm):
    ans += 1
  print(ans)