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:
n, m = map(int,input().split())
l = list(map(int,input().split()))

import math

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

ans = 1
tf = True

for i in l:
    i /= 2
    ans = lcm(ans, i)
    if (ans / i) % 2 == 0:
        print(0)
        tf = False
        break
    if ans > m:
        print(0)
        tf = False
        break

if tf == True:
    print(math.ceil(m / (ans * 2)))

Submission status: Wrong Answer

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

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

def lcm(x, y):
  return (x * y) // gcd(x,y)
  
for i in range(N):
  if a[i] % 2 != 0:
    print(0)
    exit()

x = a[0] // 2
for i in range(1, N):
  x = lcm(x, a[i] // 2)
  if x >= M:
    exit()

ans = 0
if M >= x:
  ans = 1
  M -= x
  ans += M // (x * 2)

print(ans)

Submission status: Wrong Answer

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

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

def lcm(x, y):
  return (x * y) // gcd(x,y)
  
for i in range(N):
  if a[0] % 2 != 0:
    print(0)
    exit()
x = a[0] // 2
for i in range(1, N):
  x = lcm(x, a[i] // 2)
  if x >= M:
    exit()

ans = 0
if M >= x:
  ans = 1
  M -= x
  ans += M // (x * 2)

print(ans)

Submission status: Wrong Answer

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

import math

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

ans = 1
tf = True

for i in l:
    i /= 2
    ans = lcm(ans, i)
    if (ans / i) % 2 == 0 or ans > m:
        print(0)
        tf = False
        break

if tf == True:
    print(math.ceil(m / (ans * 2)))

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
a = {int(i) // 2 for i in input().split()}

# aの中で一番小さい数が2で何回割れるか
n_2 = 0
min_a = min(a)
while True:
    if min_a % 2 != 0:
        break
    min_a //= 2
    n_2 += 1

# aのすべての数が2でn_2回割り切れる
cond1 = all({i % (2**n_2) == 0 for i in a})
# n_2回割った後、さらに2で割り切れる数は存在しない
cond2 = all({(i // (2**n_2)) % 2 != 0 for i in a})

if cond1 and cond2:
    M //= 2 ** n_2
    ans = -(-M // 2)
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N, M = [int(x) for x in input().split()]
    a = sorted(list({int(x) for x in input().split()}), reverse=True)
    x = a[0]
    p2 = 1
    while x % 2 == 0:
        p2 *= 2
        x //= 2
    flag = False
    for i in range(len(a)):
        if a[i] % p2 != 0 or (a[i] // p2) % 2 == 0:
            flag = True
            break
        a[i] //= 2
    if flag:
        print(0)
    # a = np.sort(np.unique(np.array([int(x) for x in input().split()]) // 2))[::-1]
    b = [a[0]]
    for i in range(1, len(a)):
        flag = False
        for x in b:
            if x % a[i] == 0:
                flag = True
                break
        if not flag:
            b.append(a[i])
    # print(b)
    y = 1
    for x in b:
        # print(b)
        y *= x
    z = M // y
    # print(y, z*y)
    ret = z // 2 if z % 2 == 0 else z // 2 + 1
    print(ret)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions,sys

n,m=map(int,input().split())
a = list(map(int, input().split()))
# ans = a[0]
# for i in range(1,n):
#     ans = ans * a[i] // fractions.gcd(ans, a[i])
 
 
b = [int(i/2) for i in a]
b_list=[i%4==0 for i in b]
bb=sum(b_list)
if bb!=0 and bb!=n:
    print(0)
    exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

# tf=[(ans2/i)%2==0 for i in b]
# and any(tf)
if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Wrong Answer

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

half = [i//2 for i in A]

def f(v):
    r = 0
    while v % 2 == 0:
        v /= 2
        r += 1
    return r

from fractions import gcd
def f2(x, y):
    return (x * y) // gcd(x, y)

d = f(A[0])
for ai in A:
    if d != f(ai):
        print(0)
        break
else:
    lcm = 1
    for ai in half:
        lcm = f2(lcm, ai)

    r = M // lcm
    ans = (r + 2) // 2
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

half = [i//2 for i in A]

def f(v):
    r = 0
    while v % 2 == 0:
        v /= 2
        r += 1
    return r

d = f(A[0])
for ai in A:
    if d != f(ai):
        print(0)
        break
else:
    print('wip')

Submission status: Wrong Answer

Solution code:
import fractions
 
n,m=map(int,input().split())
a = list(map(int, input().split()))
# ans = a[0]
# for i in range(1,n):
#     ans = ans * a[i] // fractions.gcd(ans, a[i])
 
 
b = [int(i/2) for i in a]
ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])


if ans2>m or ans2&2==0:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Wrong Answer

Solution code:
import fractions
 
n,m=map(int,input().split())
a = list(map(int, input().split()))
# ans = a[0]
# for i in range(1,n):
#     ans = ans * a[i] // fractions.gcd(ans, a[i])
 
 
b = [int(i/2) for i in a]
ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])


if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N, M = [int(x) for x in input().split()]
    a = sorted(list({int(x) for x in input().split()}))
    x = a[0]
    p2 = 1
    while x % 2 == 0:
        p2 *= 2
        x //= 2
    flag = False
    for i in range(len(a)):
        if a[i] % p2 != 0 or (a[i] // p2) % 2 == 0:
            flag = True
            break
        a[i] //= 2
    if flag:
        print(0)
    # a = np.sort(np.unique(np.array([int(x) for x in input().split()]) // 2))[::-1]
    b = [a[0]]
    for i in range(1, len(a)):
        flag = False
        for x in b:
            if x % a[i] == 0:
                flag = True
                break
        if not flag:
            b.append(a[i])
    # print(b)
    y = 1
    for x in b:
        # print(b)
        y *= x
    z = M // y
    # print(y, z*y)
    ret = z // 2 if z % 2 == 0 else z // 2 + 1
    print(ret)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

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

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

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a[1:], start=1):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()
 
print((m // lcm_ + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import functools

N, M = [int(i) for i in input().split()]
a = {int(i) // 2 for i in input().split()}

min_a = min(a)
count_2 = 0
while True:
    if min_a % 2 != 0:
        break
    min_a //= 2
    count_2 += 1

if any({i % 2**count_2 != 0 for i in a}):
    print(0)
    exit()


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


all_lcm = functools.reduce(lcm, a)
ans = -((-(M // all_lcm)) // 2)

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = 1
for e in a:
    lcm_all = lcm(lcm_all, e)
    if (lcm_all // e) % 2 == 0:
        print(0)
        exit()
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = 1
for e in a:
    lcm_all = lcm(lcm_all, e)
    if (lcm_all // e) % 2 == 0:
        print(0)
        exit()
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import functools

N, M = [int(i) for i in input().split()]
a = {int(i) // 2 for i in input().split()}


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


all_lcm = functools.reduce(lcm, a)
ans = -(-M // all_lcm) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
    if (lcm_all // a[i]) % 2 == 0:
        print(0)
        exit()
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)#長さがN

def divi(a):
  ans = 0
  while a % 2 == 0:
    a = a / 2
    ans += 1
  return ans

check = divi(A[0])
for i in range(N):
  if A[i] % (2 ** check) == 0:
    if A[i] % (2 ** (check + 1)) != 0:
      A[i] = A[i] / 2
    else:
      print("0")
      quit()
  else:
    print("0")
    quit()
      
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def half_lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

min_A = half_lcm_list(A)

#print(min_A)
ans = 0
if min_A > M:
  ans = 0
else:
  ans = 1
  ans += int((M - min_A) / (min_A * 2))
  
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)#長さがN

def divi(a):
  ans = 0
  while a % 2 == 0:
    a = a / 2
    ans += 1
  return ans

check = divi(A[0])
for i in range(N):
  if divi(A[i]) != check:
    print("0")
    quit()
  else:
    A[i] = A[i] / 2
  

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

min_A = half_lcm_list(A)

#print(min_A)
ans = 0
if min_A > M:
  ans = 0
else:
  ans = 1
  ans += int((M - min_A) / (min_A * 2))
  
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import math
n,m = map(int,input().split())
l = list(map(int,input().split()))
count = 0
while True:
    if l[0] % 2 == 0:
        l[0] //= 2
        count += 1
    else:
        break

for i in range(1,n):
    l[i] //= 2**count
    if l[i] % 1 != 0 or l[i] % 2 == 0:
        print(0)
        exit()
    

ans = l[0]
for i in range(1,n):
    ans = ans * l[i] //fractions.gcd(ans,l[i])

ans1 = math.ceil((m//2**(count-1))/ans)


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

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
    if (lcm_all // 2) == 0:
        print(0)
        exit()
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import functools

N, M = [int(i) for i in input().split()]
a = {int(i) for i in input().split()}


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


all_lcm = functools.reduce(lcm, a)
ans = -(-(M*2 // all_lcm) // 2)

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = a[0]
flg = False
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
    if (lcm_all // a[i]) % 2 == 0:
        print(0)
        flg = True
        break
if not flg:
    print(math.ceil((m // lcm_all) / 2))

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

Bs = [A//2 for A in As]

lcmB = reduce(lcm, Bs)

num = M // lcmB
print((num+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = a[0]
flg = False
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
print(math.ceil((m // lcm_all) / 2))

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = a[0]
flg = False
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
    if (lcm_all // a[i]) % 2 == 0:
        print(0)
        flg = True
        break
if not flg:
    print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = a[0]
flg = False
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
    if lcm_all % 2 == 0:
        print(0)
        flg = True
        break
if not flg:
    print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
n,m=map(int,(input().split()))
A=set(map(int,input().split()))
H=[]
def gcd(a, b):
    if b>a:
        return gcd(b,a)
    else:
        if b==0:
            return a
        else:
            return gcd(b,a%b)        
G=0
cnt=0
kake=1
for a in A:
    cnt+=1
    h=a//2
    if h%2==0:
        flag=0
    else:
        flag=1
    kake*=h
    if G==0:
        G=h
    else:
        G=gcd(G,h)
if kake%2==1:
    flag=0
L=kake//(G**(cnt-1))
kazu=m//L
if flag ==0:
    print(kazu//2 if kazu%2==0 else (kazu+1)//2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(set(map(lambda x: int(x) // 2, input().split())))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 ** mx_2) != 0 or g % (2 ** (mx_2 + 1)) == 0:
    print(0)
else:
    prod = 1
    lcm = 0
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)
    lcm = prod // (g ** (len(a) - 1))

    print((m // lcm + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 ** mx_2) != 0 or g % (2 ** (mx_2 + 1)) == 0:
    print(0)
elif g % 2 != 0:
    print(0)
else:
    prod = 1
    lcm = 0
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)
        if prod // g > m:
            print(0)
            sys.exit()
    lcm = prod // (g ** (len(a) - 1))

    print((m // lcm + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 ** mx_2) != 0 or g % (2 ** (mx_2 + 1)) == 0:
    print(0)
elif g % 2 != 0:
    print(0)
else:
    prod = 1
    lcm = 0
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)
        if prod // g > m:
            print(0)
            sys.exit()
    lcm = prod // (g ** len(a))

    print((m // lcm + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 * mx_2) != 0 or g % (2 * (mx_2 + 1)) == 0:
    print(0)
elif g % 2 != 0:
    print(0)
else:
    prod = 1
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)
        if prod // g > m:
            print(0)
            sys.exit()

    lm = prod // g
    print((m // lm + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 * mx_2) != 0 or g % (2 * (mx_2 + 1)) == 0:
    print(0)
else:
    prod = 1
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)
        if prod // g > m:
            print(0)
            sys.exit()

    lm = prod // g
    print((m // lm + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions

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

g = 0
mx_2 = 0
for i in a:
    tmp = 0
    while i % (2 ** tmp) == 0: tmp += 1
    mx_2 = max(mx_2, tmp - 1)
    g = fractions.gcd(g, i)

if g % (2 * mx_2) != 0 or g % (2 * (mx_2 + 1)) == 0:
    print(0)
else:
    prod = 1
    g = 0
    for i in a:
        prod *= i // 2
        g = fractions.gcd(g, i // 2)

    lm = prod // g
    print((m // lm + 1) // 2)

Submission status: Wrong Answer

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

a =  [int(x)//2 for x in input().split()]

import fractions
from functools import reduce

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

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

chk1 = True
chk2 = True
while chk1==True and chk2==True:
    cnt1=0
    for i in range(n):
        if a[i]%2==0:
            cnt1+=1
        a[i] /=2
    if n == cnt1:
        pass
    elif cnt1 ==0:
        chk2 = False
    else:
        chk1=False
    
if chk1 == False:
    print(0)
    exit()

b = lcm_list(a)

if b > m:
    print(0)
    exit()

c =(m+(b-1))//b 
print(int(c/2))

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(set(map(int, input().split())))
ah = [ai // 2 for ai in a]
lcm = reduce(mul, ah) // reduce(gcd, ah)
ans = m // (2 * lcm)
if m % (2 * lcm) >= lcm:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

a =  [int(x)//2 for x in input().split()]

import fractions
from functools import reduce

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

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

#X=ak * (p+0.5) = ak/2 * (2p+1)

chk1 = True
chk2 = True
while chk1==True and chk2==True:
    cnt1=0
    for i in a:
        if i%2==0:
            cnt1+=1
    if n == cnt1:
        pass
    elif cnt1 ==0:
        chk2 = False
    else:
        chk1=False

if chk1 == False:
    print(0)
    exit()

b = lcm_list(a)

if b > m:
    print(0)
    exit()

c =(m+(b-1))//b 
print(c//2)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import math
print(math.floor(m/max(a)-0.5)+1)

Submission status: Wrong Answer

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

a =  [int(x)//2 for x in input().split()]

import fractions
from functools import reduce

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

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

#X=ak * (p+0.5) = ak/2 * (2p+1)

chk1 = True
chk2 = True
while chk1==True and chk2==True:
    cnt1=0
    for i in a:
        if i%2==0:
            cnt1+=1
    if n == cnt1:
        continue
    elif cnt1 ==0:
        chk2 = False
    else:
        chk1=False

if chk1 == False:
    print(0)

b = lcm_list(a)

if b > m:
    print(0)
    exit()

c =(m+(b-1))//b 
print(c//2)

Submission status: Wrong Answer

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

def lcm(values):
    ans = values[0]
    for i in range(1, len(values)):
        ans = ans * values[i] // gcd(ans, values[i])
    return ans

def count_div2(value):
    count = 0
    while value % 2 == 0:
        count += 1
        value //= 2
    return count

min_value = lcm(A)
amount = M * 2 // min_value

amount_div2 = count_div2(amount)
if any([count_div2(a) != amount_div2 for a in A]):
    print(0)
else:
    print((amount + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i]//=2
    
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])


cans=m//ans
if cans%2==0:
    print(cans//2)
else:
    cans=(cans+1)//2
    print(cans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
from functools import reduce
import operator
INF = float("inf")


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


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, M: int, a: "List[int]"):

    # 各aを2で割れる回数(の２べき)
    K = set()
    for i, av in enumerate(a):
        K.add(av & -av)
    if len(K) != 1:
        print(0)
        return
    beki = K.pop()

    # 2のべきで割っておく
    b = [av // beki for av in a]

    # bの最小公倍数を求める
    gcd = b[0]
    lcm = b[0]
    for bb in b:
        gcd = GCD(gcd, bb)
        lcm = LCM(lcm, bb)

    print(int(M/(beki*lcm)) + 1)
    # 50 82
    # print(int((M/(beki*lcm)-1)/2))

    # if lcm % 2 == 0:
    #     print(0)
    #     return
    # else:
    #     print(int((M-lcm)/(2*lcm))+1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=tuple(map(lambda x:int(x)//2,input().split()))
    l=a[0]
    for x in a[1:]:
        if l%2==0:
            print(0)
            exit()
        l=l*x//gcd(l,x)
    print((M+l)//(l*2))

        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

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

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        exit()

l = 1
for i in A:
    l = l * i // fractions.gcd(l, i)
 
print((m // l + 1) // 2)

"""
num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))
"""

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

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

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        flag=1

num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
from functools import reduce
import operator
INF = float("inf")


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


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, M: int, a: "List[int]"):

    # 各aを2で割れる回数(の２べき)
    K = set()
    for i, av in enumerate(a):
        K.add(av & -av)
    if len(K) != 1:
        print(0)
        return
    beki = K.pop()

    # 2のべきで割っておく
    b = [av // beki for av in a]

    # bの最小公倍数を求める
    gcd = b[0]
    lcm = b[0]
    for bb in b:
        gcd = GCD(gcd, bb)
        lcm = LCM(lcm, bb)

    # print(beki)
    # print(lcm)
    print(int(M/(beki*lcm))+1)
    # print(int((M/(beki*lcm)-1)/2))

    # if lcm % 2 == 0:
    #     print(0)
    #     return
    # else:
    #     print(int((M-lcm)/(2*lcm))+1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
from functools import reduce
import operator
INF = float("inf")


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


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, M: int, a: "List[int]"):

    # 各aを2で割れる回数(の２べき)
    K = set()
    for i, av in enumerate(a):
        K.add(av & -av)
    if len(K) != 1:
        print(0)
        return
    beki = K.pop()

    # 2のべきで割っておく
    b = [av // beki for av in a]

    # bの最小公倍数を求める
    gcd = b[0]
    lcm = b[0]
    for bb in b:
        gcd = GCD(gcd, bb)
        lcm = LCM(lcm, bb)

    print(int((M/(beki * lcm)))+1)

    # if lcm % 2 == 0:
    #     print(0)
    #     return
    # else:
    #     print(int((M-lcm)/(2*lcm))+1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions


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

    l = a2N[0]
    for i in range(1, N):
        l = l * a2N[i] // fractions.gcd(l, a2N[i])
        if M < l:
            l = 9999999999999999999
            break

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


main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(len(a)):
    a[i]//=2
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

t = a[0]
for i in range(1,n):
    t = lcm(t,a[i])
if t==0:
    print(0)
elif m//t - m//(t*2)<0:
    print(0)
else:
    print(m//t - m//(t*2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(len(a)):
    a[i]//=2
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

t = a[0]
for i in range(2,n):
    t = lcm(t,a[i])
if t==0:
    print(0)
elif m//t - m//(t*2)<0:
    print(0)
else:
    print(m//t - m//(t*2))

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
import math

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

A = []
for a in AA:
    A.append(a//2)

def f(x):
    c = 0
    while x%2 == 0:
        c += 1
        x //= 2
    return c

a0 = f(A[0])
for a in A:
    if f(a) != a0:
        print(0)
        sys.exit()

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

l = A[0]
for a in A:
    l = lcm(l,a)

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