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())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
 
count = 0
p = 0
while res * (2 * p + 1) <= M:
    count += 1
    p += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = set(A)
D = 1

for i in B:
    D *= i//2

if M < D:
    print(0)
else:
    print(math.ceil(M/2/D))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
 
count = 0
for i in range(M):
  if res * (2 * i + 1) <= M:
    count += 1
  else:
    break
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
 
count = 0
for i in range(M):
  count += 1
  if res * (2 * i + 1) > M:
    break
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]

def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
count = 0
for i in range(int(M/res)-1):
    count += 1
print(count)

Submission status: Wrong Answer

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

if len(set(A)) == 1:
    print(-1)
    exit()

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

step = max(A)
X = step // 2
while X <= M:
    for a in A:
        if (X - a // 2) % a != 0:
            break
    else:
        cnt = X // LCM + (M - X) // LCM + 1
        print(cnt)
        exit()
    X += step
print(0)

Submission status: Wrong Answer

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

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

print(LCM)

Submission status: Wrong Answer

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

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

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

flag = False
for i in range(len(a)-1):
   if a[i]%2 != a[i+1]%2:
       flag = True
       break

while len(a)>1:
    p1 = a.pop()
    p2 = a.pop()
    a.append(lcm(p1,p2))

if flag:
    print(0)
else:
    print((m-a[0])//(a[0]*2) + 1 if m-a[0]>0 else 0)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import math
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

l=a[0]
cnt=0
while a[0]%2==0:
    a[0]=a[0]//2
    cnt+=1
    
for i in range(1,n):
    l=lcm(l,a[i]) 
    x=0
    while a[i]%2==0:
        a[i]=a[i]//2
        x+=1
    if x!=cnt:
        print(0)
        exit()

print(math.ceil(m/l))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

N, M = map(int, input().split())
a = set(map(int, input().split()))
tgcd = 0
tko = 1
for i in a:
    tgcd = gcd(tgcd, (i // 2))
    tko *= i // 2
koubai = tko // tgcd

tmp = M // koubai
if tmp == 0:
    print(0)
else:
    print((tmp // 2) + 1)

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
a=list(map(int,input().split()))
c=0
ans = a[0]/2
for i in range(1, N):
  ans = ans * (a[i]/2) // fractions.gcd(ans, a[i]/2)
S=ans
S1=S
t=0
while t != N and S1 <= M:
  t=0
  for i in range(N):
    if (S1/(a[i]/2))%2 == 1:
      t=t+1
  S1 = S1 + S
if t==N and S1 < M:
  print(int(M//S1)+1)
elif t==N and S1==M:
  print(M//S1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(N):
  if a[i]%2 == 0:
    c=c+1
if c==N:
  ans = a[0]//2
  for i in range(1, N):
      ans = ans * (a[i]//2) // fractions.gcd(ans, a[i]//2)
  S=ans
  S1=S
  t=0
  while t != N and S1 <= M:
    t=0
    for i in range(N):
      if (S1//(a[i]//2))%2 == 1:
        t=t+1
    S1 = S1 + S
  if t==N and S1 <= M:
    print(M//S1+1)
  else:
    print(0)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
a=list(map(int,input().split()))
ans = a[0]//2
for i in range(1, N):
    ans = ans * (a[i]//2) // fractions.gcd(ans, a[i]//2)
S=ans
S1=S
t=0
while t != N and S1 <= M:
  t=0
  for i in range(N):
    if (S1//(a[i]//2))%2 == 1:
      t=t+1
  S1 = S1 + S
if t==N and S1 <= M:
  print(M//S1+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
a=list(map(int,input().split()))
ans = a[0]//2
for i in range(1, N):
    ans = ans * (a[i]//2) // fractions.gcd(ans, a[i]//2)
c=0
S=ans
S1=S
t=0
while t != N and S1 <= M:
  t=0
  for i in range(N):
    if (S1//(a[i]//2))%2 == 1:
      t=t+1
  S1 = S1 + S
if S1 > M:
  print(0)
else:
  print(M//S1+1)

Submission status: Wrong Answer

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

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

tmp = a[0] // 2
for i in range(n - 1):
  tmp = lcm(tmp, a[i + 1] // 2)
print(m // tmp - m // (tmp * 2))

Submission status: Wrong Answer

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

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

tmp = a[0] 
for i in range(n - 1):
  tmp = lcm(tmp, a[i + 1])
print(m // (tmp // 2) - m // tmp)

Submission status: Wrong Answer

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

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

tmp = a[0] 
for i in range(n - 1):
  tmp = lcm(tmp, a[i + 1])
  if tmp > m * 2:
    break
print(m // (tmp // 2) - m // tmp)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
# 長さN
# 整数M
N, M = map(int, input().split())

# 長さNからなる偶数列: a
# 0.5倍しておく
#a = list(set(map(int, input().split())))
a = [i // 2 for i in set(list(map(int, input().split())))]
#print(a)

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)



if M//(lcm_list(a)) == 0:
    print(0)
else:
    print(M//(lcm_list(a))+1)

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
#重複要素を削除して要素数でLがすべて一緒か判断
def set_list(es):
    return len(list(set(es))) == 1

if set_list(L) != 1:
    print(0)
    exit()

#div内の最小子公倍数Tを求める
T = 1
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Wrong Answer

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

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

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

while len(a)>1:
    p1 = a.pop()
    p2 = a.pop()
    a.append(lcm(p1,p2))

print((m-a[0])//(a[0]*2) + 1 if m-a[0]>0 else 0)

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def log2N (x):
    c = 0
    while True:
        if x % 2 != 0:
            return c
        x = x // 2
        c = c + 1


def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
            return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

p = log2N(B[0])
print(p)
for i in range(1,len(B)):
    print(log2N(B[i]))
    if p != log2N(B[i]):
        print(0)
        exit(0)
        
x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import fractions

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

a = [int(i/2) for i in a_list]
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

if ans < M:
    b = M // ans

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

elif ans == M:
    print(1)
else:
    print(0)

Submission status: Wrong Answer

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

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def lscm(X, Y):
    g,x,y = egcd(X,-Y)
    if ((Y-X)//2)%g == 0:
        p = x*(((Y-X)//2)//g)
        if p<0:
            p = -p-1
        p %= Y//2
        return(X*p+X//2)
    else:
        return None

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

LSCM = A[0]//2
for i in range(1,N):
    LSCM = lscm(LSCM*2,A[i])
    if LSCM is None:
        print(0)
        break

else:
    print((M-LSCM)//LCM+1)

Submission status: Wrong Answer

Solution code:
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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -= a[i] // 2

    dividor = lcm_list(a)
    if dividor == 1:
        print(m-1)
        exit()
    ans = m // dividor
    if (ans%2 == 1): ans += 1 
    ans //= 2 

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def lscm(X, Y):
    g,x,y = egcd(X,-Y)
    if ((Y-X)//2)%g == 0:
        p = x*(((Y-X)//2)//g)
        if p<0:
            p = -p-1
        p %= Y//2
        return(X*p+X//2)
    else:
        return None

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

LSCM = A[0]//2
for i in range(1,N):
    LSCM = lscm(LSCM*2,A[i])
    if LSCM is None:
        print(0)
        break

else:
    print(-(-(M-LSCM)//LCM))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import fractions

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

a = [int(i/2) for i in a_list]
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

if ans <= M:
    b = M // ans

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

Submission status: Wrong Answer

Solution code:
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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -= a[i] // 2

    dividor = lcm_list(a)
    ans = m // dividor + 1
    if (ans%2 == 0): ans += 1 
    ans //= 2 

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
def main():
    N,M = map(int,input().split())
    A = [int(x)//2 for x in input().split()]
    sub = A[0]
    for i in range(1,N):
        sub = sub*A[i]//fractions.gcd(sub,A[i])
    B = M//sub
    print((B-1)//2+1)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -= a[i] // 2

    dividor = lcm_list(a)
    ans = m // dividor
    if (ans%2 == 1): ans += 1 
    ans //= 2 

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -= a[i] // 2

    dividor = lcm_list(a)
    ans = m // dividor
    if (ans%2 == 1): ans -= 1 

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import fractions

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

a = [int(i/2) for i in a_list]
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
import sys

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

n, m = map(int, input().split())
a = [int(item) // 2 for item in input().split()]
b = [0] * n

for i in range(n):
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            b[i] += 1
            tmp /= 2
        else:
            break

    if len(set(b)) != 1:
        print(0)
        sys.exit()

a_lcm = lcm(a)
count = m // a_lcm
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int,input().split()))
A = [int(_) for _ in input().split()]

l = []
list_=[l for i in range(len(A))]
for i in range(0,N):
    j = 0
    X = A[i]*0.5
    
    list_[i]=[]

    while M > X:
        list_[i].append(X)
        j+= 1
        X = A[i]*(j+0.5)


ans = list_[0]
for y in range(1,N):
    ans=list(set(ans) & set(list_[y]))


print(len(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(nums):
    x = nums[0]
    for n in nums[1:]:
        x = (x * n) // gcd(x, n)
    return x


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

flag = True
for item in a:
    if item % 2 != 0:
        print(0)
        flag = False
        break

if flag:
    a = [item // 2 for item in a]
    a_lcm = lcm(a)
    count = m // a_lcm
    if count % 2 == 0:
        print(count // 2)
    else:
        print((count + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
def main():
    N,M = map(int,input().split())
    A = [int(x)//2 for x in input().split()]
    sub = A[0]
    for i in range(1,N):
        sub = sub*A[i]//fractions.gcd(sub,A[i])
    ans = M//sub
    if ans%2==0:
        print(ans//2)
    else:
        print((ans+1)//2)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def log2N (x):
    c = 1
    if x % 2 == 0:
        return c
    x = x // 2
    c = c + 1


def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
            return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

p = log2N(B[0])
for i in range(1,len(B)):
    if p != log2N(B[i]):
        print(0)
        exit(0)
        
x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a_list = [int(i) for i in input().split()]

c = 1
for a in a_list:
    c = c * (a // 2) // fractions.gcd(c, a // 2)
if (m // c) % 2 == 0:
    print((m // c) // 2)
else:
    print(((m // c) // 2) + 1)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a_list = [int(i) for i in input().split()]

c = 1
for a in a_list:
    if a % 4 == 0:
        print(0)
        exit()
    else:
        c = c * (a // 2) // fractions.gcd(c, a // 2)

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

Submission status: Wrong Answer

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  cm = 1
  for x in l :
    cm = lcm(x, cm)
    if(cm > 4 * M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

## 1/2の公倍数
lcm_m = lcm_multi(list(map(lambda x: int(x/2), list_a)))

if(M-lcm_m < 0) :
  print(0)
else :
  print(int((M-lcm_m) / (2*lcm_m)) + 1)

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
            return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a_list = [int(i) for i in input().split()]

c = 1
for a in a_list:
    if a % 4 == 0:
        print(0)
        exit()
    else:
        c = c * (a // 2) // fractions.gcd(c, a // 2)
print(int(((m // c) + 1) // 2))

Submission status: Wrong Answer

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    if(cm > 2 * M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Wrong Answer

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    if(cm > M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Wrong Answer

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  print(a)
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    if(cm > M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break

    print((m // L + 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 = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break
    print(int((m // L + 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 = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
        if m < L:
            print(0)
            break

    print(int((m // L + 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 = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
        if m < L:
            print(0)
            break

    print(int(math.ceil(m / L) // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
    if m < L:
        print(0)
    else:
        print(int((m // L) - (m // (2 * L))))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy
n,m = map(int,input().split())
A = np.array([int(i) for i in input().split()])//2
lcm_ = 1
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

for i in A:
    lcm_ = lcm(lcm_,i)
c = 0
lcm_2 = copy.deepcopy(lcm_)
for _ in range(20):
    if lcm_2 % 2 == 0:
        c += 1
        lcm_2 = lcm_2//2
if np.all(A%(2**c) == 0):
    c = m//lcm_
    print(c//2 + c%2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def lcm(x, y):
    from fractions import gcd
    return (x * y) // gcd(x, y)


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

lcm_n = 1
for a in A:
    lcm_n = lcm(lcm_n, a // 2)

N2 = (M // lcm_n)

print(N2 // 2 if N2 // 2 == 0 else N2 // 2 + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = map(int,input().split())
A = np.array([int(i) for i in input().split()])
A_half = A//2
lcm_ = 1
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

for i in A_half:
    lcm_ = lcm(lcm_,i)
c = m//lcm_
print(c//2 + c%2)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
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 = np.array(list(map(int, input().split())))

while all(a % 2 == 0):
    a = a / 2

ans = 0
for i in a:
    if i % 2 == 0:
        ans = 0
        break
    else:
        ans = math.ceil((math.floor(m / lcm(*a))) / 2)
        if lcm(*a) == 1:
            ans -= 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
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 = np.array(list(map(int, input().split())))
a_d = a // 2

for i in a_d:
    if i % 2 == 0:
        ans = 0
        break
    else:
        ans = math.ceil(m / lcm(*a_d) / 2)

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

lcm = lambda a,b: a*b//gcd(a,b)

tot = 1
for x in l: tot = lcm(tot,x//2)

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

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np
from functools import reduce
n, m = map(int, input().split())

a = list(map(int,input().split()))
b = []

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 check_devide2(num):
    count = 0
    for i in range(100000):
        if num % 2 == 0:
            num /= 2
            count += 1
        else:
            break
    return count

for i in a:
    b.append(check_devide2(i))

if len(set(b)) != 1:
    print(0)
else:
    a = np.array(a)
    a = a / 2
    lcm = lcm_list(a)
    ans = (m - lcm)//(lcm * 2) + 1
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
 
input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []
 
input2 = input().split()


#1個ずつリストに放り込む
for i in range(N):
    a_n.append(int(input2[i]))

#後の計算量減らすために重複した要素を削除
a_n = list(set(a_n))
 
#a_nの最小公倍数を計算 
ans = a_n[0]
for i in range(1, len(a_n)):
    ans = ans * a_n[i] // fractions.gcd(ans, a_n[i])

print(round(M / ans))

Submission status: Wrong Answer

Solution code:
import fractions
 
input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []
 
input2 = input().split()


#1個ずつリストに放り込む
for i in range(N):
    a_n.append(int(input2[i]))

#後の計算量減らすために重複した要素を削除
a_n = list(set(a_n))
 
#a_nの最小公倍数を計算 
ans = a_n[0]
for i in range(1, len(a_n)):
    ans = ans * a_n[i] // fractions.gcd(ans, a_n[i])

#最小公倍数の偶奇は？奇数の場合は最小公倍数×奇数で表せるM以下の数は？
if ans % 2 == 0:
    print(0)
else:
    print(round(M / ans))

Submission status: Wrong Answer

Solution code:
import fractions
 
input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []
 
input2 = input()
 
for i in range(N):
    a_n.append(input2.split()[i])

a_n = list(map(int,(set(a_n))))
 
 
ans = a_n[0]
for i in range(1, len(a_n)):
    ans = ans * a_n[i] // fractions.gcd(ans, a_n[i])
 
print(round(M / ans))

Submission status: Wrong Answer

Solution code:
import fractions
 
input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []
 
input2 = input()
 
for i in range(N):
    a_n.append(input2.split()[i])
 
a_n.sort()
a_n = list(map(int,(set(a_n))))
 
 
ans = a_n[0]
for i in range(1, len(a_n)):
    ans = ans * a_n[i] // fractions.gcd(ans, a_n[i])
 
print(round(M / ans))