Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math

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

g = 1
for i in a:
    g = g * i // math.gcd(g, i)
ans = (m - g // 2) // g + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
nums = list(map(int, input().split()))
lcm = 1
for num in nums:
  lcm = lcm*(num//2)//math.gcd(lcm, num//2)
# print(lcm)
print((M+lcm)//(lcm*2))

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
nums = list(map(int, input().split()))
lcm = 1
for num in nums:
  lcm = lcm*(num//2)//math.gcd(lcm, num//2)
print(lcm)
print((M+lcm)//(lcm*2))

Submission status: Wrong Answer

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())



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

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

from functools import reduce

n,m=sep()
ar=lis()
temp=[]
for i in ar:
    temp.append(i//2)

k=temp[0]
for i in range(1,n):
    if k>m:
        print(0)
        quit()
    k=lcm(k,temp[i])
# print(k)
t=(m//k)
print((t+1)//2)

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,M = i_map()
    a = i_list()

    cd = []
    new_a = []
    for i in a:
        cd.append(i//2)
        new_a.append((i//2))

    while True:
        o = []
        e = []
        k = 2
        for i in new_a:
            if i%2 == 1:
                o.append(1)
            else:
                e.append(i)
        if len(e) == 0:
            break
        if len(o) > 0 and len(e) > 0:
            print(0)
            exit()
        k *= 2

    g = cd[0]
    for i in cd[1:]:
        g = g*i//gcd(g,i)
    print(math.ceil(M/g/2))








if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,M = i_map()
    a = set(i_list())
    m = max(a)
    a.remove(m)

    t = 0.5

    while True:
        trial = m*t*2
        t_lis = []
        for i in a:
            if trial % i == 0:
                t_lis.append(i)
        for j in t_lis:
            a.remove(j)
        if len(a) == 0:
            break
        t += 1
    if t*m > M:
        print(0)
        exit()
    print(math.ceil(M / (t*m)/2))






if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
a = LIST()

A = sorted([x//2 for x in a], reverse=True)

lcm = A[-1]
for x in A:
	lcm = lcm*x//gcd(lcm, x)

r = lcm//A[0]
n = M//A[0]

#2p+1が1<=2p+1<=n の範囲で rの倍数となるpの個数
if r%2 == 0 or A[0]%2 == 0:
	print(0)
else:
	print(n//r - n//(2*r))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
a = LIST()

A = sorted([x//2 for x in a], reverse=True)

lcm = A[0]
for x in A[1:]:
	lcm = lcm*x//gcd(lcm, x)

r = lcm//A[0]
n = M//A[0]

#print("r={}".format(r))
#print("n={}".format(n))
#2p+1が1<=2p+1<=n の範囲で rの倍数となるpの個数
if r%2 == 0:
	print(0)
else:
	print(n//r - n//(2*r))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
a = LIST()

A = sorted([x//2 for x in a], reverse=True)

lcm = A[0]
for x in A[1:]:
	lcm = lcm*x//gcd(lcm, x)

r = lcm//A[0]
n = M//A[0]

#2p+1が1<=2p+1<=n の範囲で rの倍数となるpの個数
if r%2 == 0 or r == 1:
	print(0)
else:
	print(n//r - n//(2*r))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
a = LIST()

A = sorted([x//2 for x in a], reverse=True)

lcm = A[0]
for x in A[1:]:
	lcm = lcm*x//gcd(lcm, x)

r = lcm//A[0]
n = M//A[0]

#2p+1が1<=2p+1<=n の範囲で rの倍数となるpの個数
if r%2 == 0:
	print(0)
else:
	print(n//r - n//(2*r))

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
from collections import defaultdict
A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
D=defaultdict(int)
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    D[now]+=1
    twos=max(twos, now)
if len(set(D.values()))!=1:
    print(0)
    exit()
now=1
for i in range(N):
    now=lcm(now, B[i])

# 1.5 * 3 2*5
from math import ceil

ans=M//(now*2)+1


print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
from collections import defaultdict
A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
D=defaultdict(int)
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    D[now]+=1
    twos=max(twos, now)
if len(set(D.values()))!=1:
    print(0)
    exit()
now=1
for i in range(N):
    now=lcm(now, B[i])

# 1.5 * 3 2*5
from math import ceil
ans=M//(now*pow(2,twos))+1
#res=now+now%(2**twos)

#if M-res>0:
#    ans-=int((M-res)//now/(2**twos))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=M//now - M//(now*(2))
#res=now+now%(2**twos)

#if M-res>0:
#    ans-=int((M-res)//now/(2**twos))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=M//now - M//(now*(2**twos))
#res=now+now%(2**twos)

#if M-res>0:
#    ans-=int((M-res)//now/(2**twos))

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def f(x):
    cnt = 0
    while x%2 == 0:
        cnt += 1
        x //= 2
    return cnt
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = inpl()
a = inpl()
a = list(set(a))
c = list(set([f(x) for x in a]))
if len(c) != 1:
    print(0)
    quit()
c = c[0]
x = 1
for i in range(len(a)):
    x = lcm(a[i]//2**c, x)
print((m+x)//(2**c*x))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def f(x):
    cnt = 0
    while x%2 == 0:
        cnt += 1
        x //= 2
    return cnt
n,m = inpl()
a = inpl()
a = list(set(a))
c = list(set([f(x) for x in a]))
if len(c) != 1:
    print(0)
    quit()
x = 1
for i in range(len(a)):
    x *= a[i]//2**c[0]
print((m+x)//(2**c[0]*x))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def f(x):
    cnt = 0
    while x%2 == 0:
        cnt += 1
        x //= 2
    return cnt
n,m = inpl()
a = inpl()
a = list(set(a))
c = list(set([f(x) for x in a]))
if len(c) != 1:
    print(0)
    quit()
x = 1
for i in range(len(a)):
    x *= a[i]//2**c[0]
print((m+x)//(2*x))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def f(x):
    cnt = 0
    while x%2 == 0:
        cnt += 1
        x //= 2
    return cnt
n,m = inpl()
a = inpl()
a = list(set(a))
c = len(list(set([f(x) for x in a])))
if c != 1:
    print(0)
    quit()
x = 1
for i in range(len(a)):
    x *= a[i]//2
print((m+x)//(2*x))

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=M//now
res=now+now%(2**twos)

if M-res>0:
    ans-=int((M-res)//now/(2**twos))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=M//now
res=now+now%(twos**2)

if M-res>0:
    ans-=int((M-res)//now/(twos**2))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=M//now
res=now+now%(twos*2)

if M-res>0:
    ans-=int((M-res)//now/(twos*2))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])


from math import ceil
ans=ceil(M//now/(2*twos))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    twos=max(twos, now)


now=1
for i in range(N):
    now=lcm(now, B[i])

print(now)
from math import ceil
ans=ceil(M//now/(2*twos))

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
for i in range(N):
    B.append(A[i]//2)

now=1
for i in range(N):
    now=lcm(now, B[i])
from math import ceil
ans=ceil(M//now/2)

print(ans)

Submission status: Wrong Answer

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

A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
for i in range(N):
    B.append(A[i]//2)

now=1
for i in range(N):
    now=lcm(now, B[i])
from math import ceil
ans=ceil(M//now/2)
print(now)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
num=a[0]//2
yn=0
for i in range(1,n):
    a[i]//=2
    num=(num*a[i])//math.gcd(num,a[i])
    if num>m:
        yn=1
        break
if yn==1 or num>m:
    print(0)
else:
    ans=1
    m-=num
    ans+=m//(num*2)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
for i in range(N):
    a = A[i]
    k = 0
    while a%2==0:
        a = a//2
        k += 1
    B.append(k)
flag = 0
for i in range(1,N):
    if B[i]!=B[0]:
        flag = 1
        break
if flag==1:
    print(0)
else:
    m = 2**B[0]
    A = [A[i]//m for i in range(N)]
    a = A[0]
    for i in range(1,N):
        x = gcd(a,A[i])
        a = (a//x)*A[i]
    d = a*m
    if a>M:
        print(0)
    else:
        print((M-a)//d+1)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
for i in range(N):
    a = A[i]
    k = 0
    while a%2==0:
        a = a//2
        k += 1
    B.append(k)
flag = 0
for i in range(1,N):
    if B[i]!=B[0]:
        flag = 1
        break
if flag==1:
    print(0)
else:
    m = 2**B[0]
    A = [A[i]//m for i in range(N)]
    a = A[0]
    for i in range(1,N):
        x = gcd(a,A[i])
        a = (a//x)*A[i]
    d = a*m
    print((M-a)//d+1)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = [a//2 for a in list(mapint())]
from math import gcd
g = 0
for a in As:
    if a%2==0:
        print(0)
        exit()

common = 1
for a in As:
    common = common*a//gcd(common, a)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
a = list(set(a))
x = 1
for i in range(len(a)):
    if a[i]%4 == 0:
        print(0)
        quit()
    x *= a[i]//2
print((m+x)//(2*x))

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
a = list(set(a))
x = 1
for i in range(len(a)):
    if a[i]%4 == 0:
        print(0)
        quit()
    x *= a[i]//2
print((m-x)//(2*x)+1)

Submission status: Wrong Answer

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

g=a[0]
lcm=a[0]

for i in range(1,n):
    g=gcd(lcm,a[i])
    lcm*=a[i]
    lcm//=g

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

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

Submission status: Wrong Answer

Solution code:
import sys
inp = lambda: sys.stdin.readline()
mi = lambda: map(int, inp().split())
li = lambda: list(map(int, inp().split()))
mf = lambda: map(float,inp().split())
lf = lambda: list(map(float,inp().split()))

from fractions import gcd
def lcm(n,m):
    return n // gcd(n,m) * m

N,M = mi()
vec = li()
now = 1
for i in vec:
    now = lcm(now,i)
    if now > M * 2 + 1:
        print(0)
        sys.exit()
print((now // 2 + M) // now)

Submission status: Wrong Answer

Solution code:
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 <= m:
    ans = (m - a_0) // gcds + 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 < m:
    ans = math.ceil((m - a_0) / gcds)
elif a_0 == m:
    ans = 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 < m:
    ans = math.ceil((m - a_0) // gcds)
elif a_0 == m:
    ans = 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 < m:
    ans = (m - a_0) // gcds 
elif a_0 == m:
    ans = 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 < m:
    ans = math.ceil((m - a_0) / gcds )
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

def f( a_k ): # 2で割り切れる回数
    count = 0
    while a_k % 2 == 0:
        count += 1
        a_k = a_k // 2
    return count

b = []
f_0 = f( a[ 0 ] )
for a_k in a:
    f_k = f( a_k )
    if f_k != f_0:
        print( 0 )
        exit()
    b.append( a_k // pow( 2, f_k ) )

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

b_lcm = 1
for b_k in b:
    b_lcm = lcm( b_lcm, b_k )

# print( b_lcm, f_0, b )
print( m // ( b_lcm * pow( 2, f_0 ) ) + 1 )

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
A = list(map(int,input().split()))
a = []
for i in A:
  i = i//2
  if i%2 == 0:
    print(0)
    sys.exit()
  a.append(i)
def gcd(p,q):
  p,q = max(p,q),min(p,q)
  while q!=0:
    p,q = q,p%q
  return p
def lcm(p,q):
  return(p*q//gcd(p,q))
max_num = a[0]
for i in a[1:]:
  max_num = lcm(i,max_num)
print(((M//max_num)+1)//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(lambda a: int(a)//2, input().split()))
g = lcm(*a)
if any([2 * g // item % 2 == 0 for item in a]):
    print(0)
else:
    ans = M//g
    ans = max(math.ceil(ans/2),0)   
    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(lambda a: int(a)//2, input().split()))
g = lcm(*a)
ans = M//g
ans = max(math.ceil(ans/2),0)
    
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC150 D
from math import gcd

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

g=A[0]
for a in A:
    g=g*a//gcd(a,g)
g//=2
print(int((M/g+1)//2))

Submission status: Wrong Answer

Solution code:
# ABC150 D
from math import gcd

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

g=A[0]
for a in A:
    g=g*a//gcd(a,g)
g//=2
print((M/g+1)//2)

Submission status: Wrong Answer

Solution code:
# ABC150 D
from math import gcd

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

g=A[0]
for a in A:
    g=g*a//gcd(a,g)
g//=2
print((M//g+1)//2)

Submission status: Wrong Answer

Solution code:
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=l[0]//2
for i in range(n-1):
    a=lcm(a,l[i+1]//2)
 
ok = True
for aa in l:
    if (a//aa) % 2 != 1:
        ok = False
        break
ans = 0
if ok:
    ans = ((m//a)+1)//2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x

n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
zero = False
count = 0
#a = list(map(lambda x: x // 2, na))
mini = lcm(a)
nibai = 1
while(True):
  if mini % 2 == 0:
    nibai *= 2
    mini //= 2
  else:
    break
for i in a:
  if i % 4 * nibai == 0:
    zero = True
    break
#print(a)
if not zero:
  t = Decimal(str((m // mini) / 2))
  print(t.quantize(Decimal('0'), rounding=ROUND_HALF_UP))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x

n,m = map(int, input().split(" "))
na = list(map(int, input().split(" ")))
zero = False
count = 0
a = list(map(lambda x: x // 2, na))
mini = lcm(a)
nibai = 1
while(True):
  if mini % 2 == 0:
    nibai *= 2
    mini //= 2
  else:
    break
for i in na:
  if i % 4 * nibai == 0:
    zero = True
    break
#print(a)
if not zero:
  t = Decimal(str((m // mini) / 2))
  print(t.quantize(Decimal('0'), rounding=ROUND_HALF_UP))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x

n,m = map(int, input().split(" "))
na = list(map(int, input().split(" ")))
zero = False
for i in na:
  if i % 4 == 0:
    zero = True
    break
count = 0
a = list(map(lambda x: x // 2, na))
#print(a)
if not zero:
  mini = lcm(a)
  t = Decimal(str((m // mini) / 2))
  print(t.quantize(Decimal('0'), rounding=ROUND_HALF_UP))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]

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

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

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

if __name__ == '__main__':
    abc150_d()

Submission status: Wrong Answer

Solution code:
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]

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

    x = 1
    for a in A:
        x = lcm(x, a)
        if x > 2*m: return print(0)

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

if __name__ == '__main__':
    abc150_d()

Submission status: Wrong Answer

Solution code:
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]

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

    x = 1
    for a in A:
        x = lcm(x, a)
        if x > 2*m: return 0

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

if __name__ == '__main__':
    abc150_d()

Submission status: Wrong Answer

Solution code:
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]

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

    x = A[0]
    for a in A:
        x = lcm(x, a)
        if x > 2*m: break

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

if __name__ == '__main__':
    abc150_d()

Submission status: Wrong Answer

Solution code:
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) for x in input().split()]

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

    x = 1
    for a in A:
        x = lcm(x, a)
        if x > 2*m: break

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

if __name__ == '__main__':
    abc150_d()