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 sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
A = inpl()

AA = list(map(lambda x: x//2,A))

#lcm
def lcm(A):
    x = A[0]
    for a in A:
        x = (x * a) // math.gcd(x, a)
    return x

lcm = lcm(AA)
max = max(A)

if lcm % 2 == 0:
    sta = max + abs(lcm - max % lcm) + lcm
else:
    sta = max + abs(lcm - max % lcm)
d = 2 * lcm

cnt = m // lcm - m // (2*lcm) - sta // d + sta // (2*lcm)

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
A = inpl()

AA = list(map(lambda x: x//2,A))

flg = True
for aa in AA:
    if aa % 2 == 1:
        flg = False

if flg:
    print(0)
    exit()

#lcm
def lcm(A):
    x = A[0]
    for a in A:
        x = (x * a) // math.gcd(x, a)
    return x

lcm = lcm(AA)

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

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
A = inpl()

AA = list(map(lambda x: x//2,A))

#lcm
def lcm(A):
    x = A[0]
    for a in A:
        x = (x * a) // math.gcd(x, a)
    return x

lcm = lcm(AA)

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

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
A = inpl()

AA = list(map(lambda x: x//2,A))

#lcm
def lcm(A):
    x = A[0]
    for a in A:
        x = (x * a) // math.gcd(x, a)
    return x

lcm = lcm(AA)

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

Submission status: Wrong Answer

Solution code:
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)
    if lcm > M*2:
        print(0)
        exit()
ans = M // (lcm//2) - M // lcm
print(ans)

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
    div *= 2
    a0 //= 2
for i in range(1, N):
    a = A[i] % div
    b = A[i] // div
    if (b % 2 == 0) or (a != 0):
        print(0)
        exit()

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
cnt = 1
while a0 % 2 != 0:
    cnt *= 2
    a0 //= 2
for i in range(N):
    a = A[i] % cnt
    if (a % 2 == 0) or (a != 0):
        print(0)
        exit()

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
cnt = 1
while a0 % 2 != 0:
    cnt *= 2
    a0 //= 2
for i in range(N):
    a = A[i] // cnt
    if (a % 2 == 0) or (A[i] % cnt != 0):
        print(0)
        exit()

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import sys


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


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


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


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


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, cnt, cur = 0, 0, a_pr[0]
while cur % 2 == 0 and cur > 0:
    cur //= 2
    cnt += 1
for cur in a_pr[1:]:
    for _ in range(cnt):
        cur //= 2
        if cur % 2 == 1 or cur == 0:
            print(0)
            sys.exit()
print(int(my_round(m // lcm_ / 2)))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce


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


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


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


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


n, m = list(map(int, input().split()))
print(
    int(my_round(m // lcm_list([i // 2 for i in list(map(int, input().split()))]) / 2)))

Submission status: Wrong Answer

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

max_a = max(a)
min_a = min(a)
max_i = int(m / min_a + 0.5)
#print(max_a,min_a,max_i)
memo = {}
dic = {}
for i in range(n):
    if a[i] not in memo:
        memo.setdefault(a[i],0)
        p = 1
        x = 0
        while int(a[i] * (p + 0.5))<=m:
            x = int(a[i] * (p + 0.5))
            dic.setdefault(x,0)
            dic[x] += 1
            p += 1
cnt = 0
for dic_item in dic.items():
    if dic_item[1] == len(memo):
        cnt += 1
        #print(dic_item[0])
print(cnt)

Submission status: Wrong Answer

Solution code:
from math import gcd
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

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

def main(n,m,a):
    x=a[0]//2
    for i in range(1,n):
        x=lcm(x,a[i]//2)
    gusubai=False
    for i in range(n):
        if x%a[i]!=0:
            gusubai=True
            break
    
    y=m//x
    #print(y,x,m)
    if gusubai:
        ans=y//2+y%2
    else:
        ans=y
    return ans

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

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

def main(n,m,a):
    x=a[0]//2
    for i in range(1,n):
        x=lcm(x,a[i]//2)
    y=m//x
    #print(y,x,m)
    ans=y//2+y%2
    return ans

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=1
a=A[0]//2
p=True
while a%2==0:
  n+=1
  a=a//2
l=A[0]//2
for a in A[1:]:
  a=a//2
  m=1
  l=l*a//math.gcd(l,a)
  while a%2==0:
    m+=1
    a=a//2
  if n!=m:
    p=False
    break
ans=0
if p:
  if max(l,max(A))<=M:
    ans=M//l-M//(l*2)
print(max(0,ans))

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=1
a=A[0]//2
p=True
while a%2==0:
  n+=1
  a=a//2
l=A[0]//2
for a in A[1:]:
  a=a//2
  m=1
  l=l*a//math.gcd(l,a)
  while a%2==0:
    m+=1
    a=a//2
  if n!=m:
    p=False
    break
ans=0
if p:
  if max(l,max(A))<=M:
    ans=M//l-M//(l*2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=1
a=A[0]//2
p=True
while a%2==0:
  n+=1
  a=a//2
l=A[0]//2
for a in A[1:]:
  a=a//2
  m=1
  l=l*a//math.gcd(l,a)
  while a%2==0:
    m+=1
    a=a//2
  if n!=m:
    p=False
    break
ans=0
if p:
  if max(l,max(A))<=M:
    ans=M//(l*2)+1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=1
a=A[0]//2
p=True
while a%2==0:
  n+=1
  a=a//2
l=A[0]//2
for a in A[1:]:
  a=a//2
  m=1
  l=l*a//math.gcd(l,a)
  while a%2==0:
    m+=1
    a=a//2
  if n!=m:
    p=False
    break
ans=0
if p:
  ans=M//l//2+1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=1
a=A[0]//2
p=True
while a%2==0:
  n+=1
  a=a//2
l=A[0]//2
for a in A[1:]:
  a=a//2
  m=1
  l=l*a//math.gcd(l,a)
  while a%2==0:
    m+=1
    a=a//2
  if n!=m:
    p=False
    break
ans=0
if p:
  ans=math.ceil(M/l/2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def f(n):
    res = 0
    while n % 2 == 0:
        n = n // 2
        res += 1
    return res

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

def main():
    N, M = map(int, input().split())
    num_list = [int(i) // 2 for i in input().split()]

    p = f(num_list[0])

    for i in num_list:
        if p != f(i):
            print(0)
            return
    
    l = 1

    for i in num_list:
        i = i // 2 ** p
        l = lcm(l, i)
        if l > M:
            print(0)
            return

    M = M // l
    res = int((M+1)/2)
    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd
import sys

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

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

A.sort(reverse=True)

temp=A[0]
for i in range(1,n):
    if gcd(temp//2,A[i]//2)>1:
        print(0)
        sys.exit()
    else:
        temp=lcm(temp,A[i])

ans=m//(temp//2)-m//temp
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
import sys

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

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

A.sort(reverse=True)

temp=A[0]
for i in range(1,n):
    if temp%A[i]==A[i]//2:
        print(0)
        sys.exit()
    else:
        temp=lcm(temp,A[i])

ans=m//(temp//2)-m//temp
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import math
input = sys.stdin.readline

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

lcm = a[0]
for i in range(n):
    lcm = lcm * a[i] // math.gcd(lcm, a[i])

s = 0
if lcm % 2 == 1:
    s = 0
else:
    s = (2 * m + lcm) // (2 * lcm)

print(s)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import math
input = sys.stdin.readline

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

b = []
for x in a:
    b.append(x // 2)

lcm = b[0]
for i in range(n):
    lcm = lcm * b[i] // math.gcd(lcm, b[i])

s = (m + lcm) // (2 * lcm) 

print(s)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
n, m = input().split()
a = list(map(int, input().split()))
b =[0]*int(n)
for i in range(len(a)):
  b[i] = a[i]//2

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
c = 0

x = lcm_list(b)

for i in range(int(n)):
  if (x // b[i]) % 2 == 0:
    c = -1
    break
  else:
    continue
    
if c == -1:
  print(0)
else:
  print(math.ceil((int(m)+1)/(2*x)))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
n, m = input().split()
a = list(map(int, input().split()))
b =[0]*int(n)
for i in range(len(a)):
  b[i] = a[i]//2

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
c = 0

x = lcm_list(b)

for i in range(int(n)):
  if (x // b[i]) % 2 == 0:
    c = -1
    break
  else:
    continue
    
if c == -1:
  print('0')
else:
  print(math.ceil((int(m)+1)/(2*x)))

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce

n,m=map(int,input().split())
lst=list(map(lambda x : int(x)//2,input().split()))
divi=lst[0]//2
for i in range(1,n):
    if lst[i]//2!=divi:
        print(0)
        exit()

work=reduce(lambda x,y: x*y//gcd(x,y),lst)
print((m//work+1)//2)

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce

n,m=map(int,input().split())
lst=list(map(lambda x : int(x)//2,input().split()))
work=reduce(lambda x,y: x*y//gcd(x,y),lst)
print((m//work+1)//2)

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = [a//2 for a in  A]
lcm = 1

for i in range(n):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if lcm > m:
        print(0)
        exit()

print(ceil((m // lcm) / 2))

Submission status: Wrong Answer

Solution code:
from math import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = [a//2 for a in  A]
lcm = 1

for i in range(n):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if lcm > m:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from math import gcd

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

lcm = 1

for i in range(n):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if lcm > m*2:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
import math

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

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

# 最小公倍数を求める (数列を2で割る)
# Mの中に最小公倍数の倍数がどれくらいあるかを求める
# そのうちの偶数を除く ー＞ 答え

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

ans = M // lm

if lm % 2 != 0:
    print(ans // 2 + 1 if ans % 2 != 0 else ans // 2)
else:
    print(ans // 2)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

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

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

# 最小公倍数を求める (数列を2で割る)
# Mの中に最小公倍数の倍数がどれくらいあるかを求める
# そのうちの偶数を除く ー＞ 答え

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

ans = M // lm if M % lm != 0 else M // lm - 1

print(ans // 2 + 1 if ans % 2 != 0 else ans // 2)

Submission status: Wrong Answer

Solution code:
import math

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

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

# 最小公倍数を求める (数列を2で割る)
# Mの中に最小公倍数の倍数がどれくらいあるかを求める
# そのうちの偶数を除く ー＞ 答え

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

ans = M // lm

print(ans // 2 + 1 if ans % 2 != 0 else ans // 2)

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

from functools import reduce

def lcm(vals):
    return reduce((lambda x, y: (x * y) // math.gcd(x, y)), vals, 1)

(N, M) = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

ha = []
answer = -1
for a in A:
    if a % 2 != 0:
        answer = 0
        break
    else:
        ha.append(a // 2)

if answer != 0:
    answer = (M // lcm(ha) + 1) // 2

print(answer)

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce
import sys
input = sys.stdin.readline


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


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

    lcm_a = reduce(lcm, A)
    step = lcm_a * 2
    ans = (m + lcm_a) // step
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd
def lcm(x,y):
    return x*y//gcd(x,y)
n,m = map(int,input().split())
a = [i//2 for i in list(map(int,input().split()))]
t = 1
for i in range(n):
    t = lcm(t,a[i])
ans = m//t-m//(2*t)
i = 2
while m >= t*2**i:
    ans += m//(t*2**i)
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
def lcm(x,y):
    return x*y//gcd(x,y)
n,m = map(int,input().split())
a = [i//2 for i in list(map(int,input().split()))]
t = 1
for i in range(n):
    t = lcm(t,a[i])
print(m//t-m//(2*t))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

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

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

if reduce(math.gcd, A)%2:
  min_x = int(lcm(A)*0.5)
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from functools import reduce  # @lru_cache(None)
from math import gcd

n, m = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
B = [a // 2 for a in set(A)]
g = reduce(gcd, B)
if g != 1 or (len(B) > 1 and min(B) == 1):
    print(0)
    exit()

l = 1
for b in B:
    l = l * b // gcd(l, b)
    if l > m:
        print(0)
        exit()
    g = gcd(g, b)

limit = m // l
ans = (limit + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

n, m = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
B = [a // 2 for a in A]

lcm = 1
for b in B:
    lcm = lcm * b // gcd(lcm, b)
    if lcm > m:
        print(0)
        exit()

limit = m // lcm
ans = (limit + 1) // 2
print(ans)

Submission status: Wrong Answer

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

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

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

x = A[0]
for a in A[1:]:
  x = lcm(x,a)
  
print((M // x + 1)//2)

Submission status: Wrong Answer

Solution code:
import numpy as np

inp = input()
N = int(inp.split(' ')[0])
M = int(inp.split(' ')[1])

inp2 = input()
A = list(set([int(i) for i in inp2.split(' ')]))

min_c = np.min(A)
max_c = np.max(A)
A.remove(max_c)

max_list = [i for i in range(int(max_c/2), M, max_c)]

for j in A:
  max_list = [i for i in max_list if i%j==j/2]
  
print(len(max_list))

Submission status: Wrong Answer

Solution code:
import numpy as np

inp = input()
N = int(inp.split(' ')[0])
M = int(inp.split(' ')[1])

inp2 = input()
A = list(set([int(i) for i in inp2.split(' ')]))

min_c = np.min(A)
max_c = np.max(A)
A.remove(max_c)

max_list = [i for i in range(int(max_c/2), M, max_c)]

for j in A:
  a_list = [i for i in range(int(j/2), M, j)]
  max_list = list(set(a_list) & set(max_list))

print(len(max_list))

Submission status: Wrong Answer

Solution code:
from collections import deque,defaultdict
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]
for i in range(1,n):
    tmp = lcm(tmp,A[i])
ans = m//tmp
lis = set()
for i in A:
    r = i
    k=0
    while(r%2==0):
        k+=1
        r//=2
    lis.add(k)
if(m//(tmp)*tmp+tmp//2<=m):
    ans += 1
if(tmp//2 in A or len(lis)!=1):
    ans=0
if (n==1):
    ans = m//A[0]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque,defaultdict
import math
import numpy as np
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]//2
res=0
for i in range(1,n):
    tmp = lcm(tmp,A[i]//2)
lis = set()

for i in A:
    r = i
    k=0
    while(r%2==0):
        k+=1
        r//=2
    lis.add(k)
if(len(lis)>1):
    print(0)
else:
    print(m//tmp)

Submission status: Wrong Answer

Solution code:
from collections import deque,defaultdict
import math
import numpy as np
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]//2
res=0
for i in range(1,n):
    tmp = lcm(tmp,A[i]//2)
if(tmp!=0):
    res=math.ceil((m/(tmp*2)))
k = 0
r = min(A)
while(r%2==0):
    k+=1
    r//=2
for i in A:
    if(i%(2**k)!=0):
        res = 0
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

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

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

a2 = [i//2 for i in a]

a2_l = lcm(*a2)
print(m//a2_l - m//(a2_l*2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

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

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

a2 = [i//2 for i in a]

a2_l = lcm(*a2)
print(m//a2_l - m//2//a2_l)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

    mini_multi=int(np.lcm.reduce(A_double))

    res=M//mini_multi

    if res%2!=0:
        res+=1


    print(res//2)





if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

    mini_multi=int(np.gcd.reduce(A_double))

    res=M//mini_multi

    if res%2!=0:
        res+=1


    print(res//2)





if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions

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

    k=A_double[0]
    mini_multi=A_double[0]
    for i in range(len(A_double)):
        k=fractions.gcd(mini_multi,A_double[i])
        mini_multi=(mini_multi*A_double[i])//k
    res=M//mini_multi

    if res%2!=0:
        res+=1
    
    
    print(res//2)





if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions

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

    k=A_double[0]
    mini_multi=A_double[0]
    for i in range(len(A_double)):
        k=fractions.gcd(mini_multi,A_double[i])
        mini_multi=(mini_multi*A_double[i])//k
    res=M//mini_multi

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





if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions

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

    k=A_double[0]
    mini_multi=A_double[0]
    for i in range(len(A_double)):
        k=fractions.gcd(mini_multi,A_double[i])
        mini_multi=(mini_multi*A_double[i])//k


    res=M//mini_multi

    if res%2!=0:
        res+=1
    print(res//2)





if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd

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

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

lcm_of_half_As = 1
for A in As:
    lcm_of_half_As = lcm(lcm_of_half_As, A //  2)
    if lcm_of_half_As > M:
        break

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

Submission status: Wrong Answer

Solution code:
import math ,copy
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)
b = copy.deepcopy(a)
T=[0]*N
t=0
#while b[i]%2==0:
 #   b[i]= b[i]//2
  #  t+=1
#T[0]=t
r=True
for i in range(N):
    t=0
    while b[i]%2==0:
        b[i]= b[i]//2
        t+=1
    T[i]=t
    if T[0]!=T[i]:
        r=False
        break
#print(T)
#print(r)
if r: 
    
    a[0]=int(a[0]/(2**T[0]))
    num=a[0]
    for i in range(1,N):
        a[i]=int(a[i]/(2**T[0]))
        num=lcm(a[i],num)
    M=M/(2**(T[0])-1)
    #print(num)
    if num>(M):
        print(0)
    else:
        print(math.ceil(int(M/num)/2))
else:
    print(0)