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 fractions
def Lcm(X,Y):
  return X*Y//fractions.gcd(X,Y)
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
c=1
ans=1
while ls[0]%2==0:
  ls[0]//=2
  c*=2
for i in range(1,N):
  if ls[i]%c!=0:
    ans=0
    break
  elif ls[i]%(2*c)==0:
    ans=0
    break
  else:
    ls[i]//=c
  #print(ls)
if ans==0:
  print(0)
else:
  lcm=1
  for e in ls:
    lcm=Lcm(lcm,e)
    if lcm*c>M:
      print(1)
      print(lcm)
      break
  else:
    x=lcm*c//2
    y=M//x+1
    #print(x)
    print(max([y//2,0]))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
	if not b:
		return a
	return gcd(b,a%b)

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

n,m=map(int,input().split())
arr=[int(x)//2 for x in input().split()]

L=arr[0]
for x in range(1,n):
	L=lcm(L,arr[x])

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

A=list(map(int,input().split()))
B=list(map(lambda x: x//2, A))

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B=[A[-1]//2]


if M<B[-1]:
    print(0)
else:
    print((M-B[-1])//A[-1]+1)

Submission status: Wrong Answer

Solution code:
# D
import fractions
import math
N, M = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
if (ans <= M):
    print(math.ceil(M / ans))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

import math
from fractions import gcd




def main():
	n,m=map(int,input().split())
	a=list(map(int,input().split()))
	b=[]
	
	for i in a:
		b.append(i//2)
	l=1
	for i in b:
		l=l*i//gcd(l, i)
	
	ans=(m)/(2*l)+0.5
	ans=math.floor(ans)
	print(ans)


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

m = lcm(b)
    
ans = int((M//m+1)//2);
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
i = input().split(" ")
N = int(i[0])
M = int(i[1])

a = input().split(" ")
a = [int(i) for i in a]
a_h = [i / 2 for i in a]

g = lcm_list(a_h)
kisu = [(g / i) % 2 for i in a_h]
if sum(kisu) == len(kisu): # 入力の半分の最小公倍数が入力の奇数倍すべて
  g2 = lcm_list(a)
  r = (M - g) // g2 + 1
  r = int(r)
  print(r)
  
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n, m = [int(v) for v in input().split()]
alist = [int(v) for v in input().split()]
hlist = [a // 2 for a in alist]

log = {}
def gcd(m, n):
    if m < n:
        m, n = n, m
    def _gcd(p, q):
        # if (p, q) in log:
        #     return log[p, q]
        t = p % q
        res = q if t == 0 else _gcd(q, t)
        # log[p, q] = res
        return res
    return _gcd(m, n)

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

common = 1
for h in hlist:
    common = lcm(common, h)

cntwice = m // common
print(cntwice // 2 + cntwice % 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm_(x, y):
    return x * y // gcd(x, y)
if any(map(lambda x:not x&1, AA)):
    print(0)
else:
    a = reduce(lcm_, AA)
    print(M//a - M//(2*a))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for a in A[1:]:
    g=g*a//gcd(g,a)
print(M//(g//2)-M//g)

Submission status: Wrong Answer

Solution code:
import fractions

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

nums.sort()

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

def ans(nums):
    ans = lcm(nums[0], nums[1])
    if len(nums) >= 3: 
        for i in range(2, len(nums)):
            ans = lcm(ans, nums[i])
    return ans

print(M // (lcm(nums[0], nums[-1]) // 2) // 2 + 1) if (lcm(nums[0], nums[-1]))  <= M else print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(a, b):
  return (a * b) // gcd(a, b)
 
 
n, m = map(int, input().split())
a = list(set(map(int, input().split())))
n = len(a)
a = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
  if all_lcm > m:
    exit(print(0))
m -= m % all_lcm
flag = m % 2
print(m // all_lcm // 2 + flag)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
if not sum((e // 2) & 1 for e in a) in [0, n]:
    print(0)
    exit(0)
lcm = 1
for e in a:
    e //= 2
    lcm *= e // gcd(lcm, e)
    if lcm > m: break
res = (1 + m // lcm) // 2
print(res)

Submission status: Wrong Answer

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

if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

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

lcm = reduce(calc_lcm, a_set, 1)

print(m // lcm + 1 if m // lcm != 0 else 0)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a = list(map(int, input().split()))
k=0
t=a[0]
while 1:
    if t%2==0:
        k+=1
        t//=2
    else:
        break
K=2**k
from fractions import gcd
l=t
for i in a:
    if i%K==0 and (i//K)%2==1:
        t=i//K
        l=l*t//gcd(l,t)
    else:
        print(0)
        break
else:
    print((M-l)//(2*l)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

n_lcm = lcm_list(a)
h_lcm = n_lcm // 2
if h_lcm > m:
    print(0)
else:
    print((m - h_lcm)//n_lcm + 1)

Submission status: Wrong Answer

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

M *= 2
v = -1
for i in range(1, M):
    if (i % a).sum() == 0:
        v = i
        break
if v != -1:
    print((M // v + 1) // 2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
  A[i] = A[i]//2
gcd = A[0]
for i in range(1, N):
  gcd = gcd*A[i]//fractions.gcd(gcd, A[i])
print(1 + (M-gcd)//(2*gcd))

Submission status: Wrong Answer

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


import fractions
a[0]=a[0]//2
k=a[0]
for j in range(N-1):
  i=j+1
  a[i]=a[i]//2
  k=a[i]*k//fractions.gcd(k,a[i])

l=M//k
if l%2==0:
  print(l//2)
else:
  print(l//2+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(len(A)):
    A[i]=A[i]//2
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)
lcm=lcm_list(A)
answer=(M//lcm+1)//2
print(answer)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools

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

a = list(set(a))
ans = a[0]

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

num = ans // 2
if (num == 0):
    print(M//ans)
else:
    print(M//num-M//ans)

Submission status: Wrong Answer

Solution code:
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n,m,*a=map(int,open(0).read().split())
a=list(set(a))
n=len(set(a))
# print(a)
for i in range(n):
    b=f(a[i])
    for j in b:
        for k in range(i+1,n):
            if a[k]%j==0:
                a[k]//=j
# print(a)                
c=1
for i in a:
    c*=i
print(0 if c//2>m else (m-c//2)//c+1)

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

num = 1
ans = 0
if num // 2 <= m:
    ans = 1
for i in range(n):
    num = lcm(num, a[i])
ans = max(ans, math.floor((m - num // 2) / num + 1))

print(ans)

Submission status: Wrong Answer

Solution code:
'''input
5 1000000000
6 6 2 6 2
'''
# A coding delight
from sys import stdin, stdout
import gc
from copy import deepcopy
from itertools import permutations
gc.disable()
input = stdin.readline
import math


def myfunc(num):
	return num//2

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

def find_lcm(num1, num2): 
    return (num1 * num2) // gcd(num1, num2)

def lcm(l):
	if len(l) == 1:
		return l[0]
	num1 = l[0] 
	num2 = l[1] 
	lcm = find_lcm(num1, num2) 
	  
	for i in range(2, len(l)): 
	    lcm = find_lcm(lcm, l[i])
	return lcm
# main starts
n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr = list(map(myfunc, arr))
num = lcm(arr)


aux = num
while aux % 2 == 0:
	aux //= 2

if aux == 0:
	num *= 3

# print(num)
if num > m:
	print(0)
else:
	k = m//num
	if k % 2 == 0:
		print(k//2)
	else:
		print(k//2 + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

num = lcm_list([v // 2 for v in A])
print(-(-M // num) // 2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
from fractions import gcd
from functools import reduce
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template

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

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

def main():
    n, m = mi()
    a = lmi()
    cnt = 0
    while(True):
        if all(x % 2 == 0 for x in a):
            cnt += 1
            a = list(map(lambda x: x // 2, a))
        else:
            break
    c = pow(2, cnt - 1)
    for i in range(n):
        if a[i] % 2 == 0:
            print(0)
            exit()
    now = 1
    for i in range(n):
        now = lcm_base(now, a[i])
        if(c * now >= m):
            print(0)
            exit()
    la = now
    x = m // la
    print((x + 1) // (2 * c))
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

n, m = map(int, input().split())
a_str_list = input().split()

a_list = []

for item in a_str_list:
    a_list.append(int(item))

a_list = list(set(a_list))

step = lcm_list(a_list)
start = step // 2

if m - start < 0:
    print(0)
else:
    print(((m-start) // step)+1)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
a = set(input().split())
a = list(map(lambda x: int(x)//2, a))
c = 1
for n in a:
    c *= n
print(M//c - M//(c*2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

m_lcm = lcm([i // 2 for i in a])
if m_lcm > m:
  print(0)
  exit(0)

ans = 1 + (m - m_lcm) // (2 * m_lcm)
print(ans)

Submission status: Wrong Answer

Solution code:
nm = input().split()
a_series = [int(x) for x in input().split()]

N = int(nm[0])
M = int(nm[1])


totoal = []
for a in a_series:
    p = 1
    while(True):
        X = a*(p+0.5)
        totoal.append(X)
        p += 1

        if (X > M):
            break

result = list(filter(lambda x: totoal.count(x) == N, totoal))

print(len(set(result)))

Submission status: Wrong Answer

Solution code:
import fractions
#fractions.gcd(x,y)
def lcm(a,b): return a*b//fractions.gcd(a,b)

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

lcm_value = lcm_list(a_list)

print((m*2//lcm_value+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions as f

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

am = max(a)
x, oe0 = a[0], a[0] % 2
for i in range(1, len(a)):
    if a[i] % 2 != oe0:
        print(0)
        exit()
    x = x * a[i] / f.gcd(x, a[i])

ans = M // x
if x//2 <= M % x:   ans += 1
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
def GCM(a, b):
  a, b = max(a,b), min(a, b)
  r = a % b
  if r == 0:
    return b
  else:
    return GCM(b, r)

def LCD(a, b):
  g = GCM(a, b)
  return (a//g)*b

N, M = map(int, input().split())
A = list(map(int, input().split()))
X_2 = 2
for a in A:
  X_2 = LCD(X_2, a)
X = X_2//2
print(M//X-M//X_2)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
def int_2(n):
    return int(n)//2
a=list(map(int_2,input().split()))
def gcm(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return gcm(a%b,b) if a>=b else gcm(b%a,a)

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

lis=[a[0]]*n
for i in range(n-1):
    lis[i+1]=lcm(lis[i],a[i+1])

ma=m//lis[n-1] 
print((ma+1)//2)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for e in a:
    e //= 2
    lcm *= e // gcd(lcm, e)
    if lcm > m: break
if not sum(e & 1 for e in a) in [0, n]:
    print(0)
    exit(0)
res = (1 + m // lcm) // 2
print(res)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from fractions import gcd
from math import ceil
#stdin = open("input.txt")

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

if __name__ == "__main__":
  N, M = [int(i) for i in stdin.readline().split()]
  A = [int(i) for i in stdin.readline().split()]
  B = [a//2 for a in A]
  
  Blcm = lcm(B)
  
  
  if Blcm % 2 == 0:
    res = 0
  else:
    res = ceil(M/Blcm/2)
  
  print(res)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
a = rl()
A = np.array(a)
B = A * 0.5
if any(B%2==0):
    print(0)
    exit()

b = list(B)
ans = b[0]
for i in range(1, N):
    ans = ans * b[i] // fractions.gcd(ans, b[i])
if ans > M:
    answer = 0
else:
    answer = 1 + (M-ans)//(2*ans)

print(int(answer))

Submission status: Wrong Answer

Solution code:
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)

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
"""
for x in range(len(a)):
  if x[a] % 2 == 1:
    print 0
    exit(0)
"""
LCM = lcm_list(a)
if LCM%2 == 1:
  print 0
  exit(0)

m = m + (LCM / 2)
print m // LCM

Submission status: Wrong Answer

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



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



ans = lcm(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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


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

x = lcm_list(a)
print((m-x//2)//x+1)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

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


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

all_lcm = 1

for a in l:
    all_lcm = lcm(a, all_lcm)

    if all_lcm > 2 * M:
        print(0)
        sys.exit()

minimum = all_lcm / 2

if minimum > M:
    print(0)
    sys.exit()

print(1 + int((M - minimum) / all_lcm))

Submission status: Wrong Answer

Solution code:
import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n, m = map(int, readline().split())
a = list(set(list(map(int, read().split()))))
half_a = [x // 2 for x in a]


f = a[0]
f_ = half_a[0]
for i in range(1, len(a)):
    f_ = f_ * half_a[i] // fractions.gcd(f_, half_a[i])

cnt = (m // f_ + 1) // 2
print(cnt)

Submission status: Wrong Answer

Solution code:
from functools import reduce
def gcd(a,b):
    temp=a
    a=b
    b=temp%a
    if b==0:
        return a
    else:
        return gcd(a,b)

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

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

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

N,M=map(int,input().split())
a=list(map(int,input().split()))
common=lcm_list(a)
if common//2<=M:
    print((M//(common//2))//2+1)
else:
    print(0)

Submission status: Wrong Answer

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

for i,j in zip(a[:-1],a[1:]):
    ans = i*j//gcd(i,j)
if ans%2 ==0:
    print(0)
else:
    print(M//ans-M//(ans*2))

Submission status: Wrong Answer

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


def GCD(x,y):
    x,y = max(x,y),min(x,y)
    if y == 0:
        return x
    else:
        return GCD(y,x%y)
    
g = A[0]
for i in range(N-1):
    g = GCD(A[i+1],g)
    
bai = g
for a in A:
    if GCD(bai,a) == a:
        pass
    else:
        bai*=a//g
    

han = bai
while han%2 == 0:
    han//=2
    
#print(han)
ans = (M//(han*2))
if M%(2*han) >= han:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
while True:
  if a[0] % 2 == 0:
    a[0] //= 2
    cnt += 1
  else:
    break
div = 2 ** cnt
for i in range(1,n):
  if a[i] % div == 0:
    a[i] //= div
    if a[i] % 2 == 0:
      print(0)
      break
  else:
    print(0)
    break
  if cnt == 0:
    print(0)
    break
else:
  #print(a)
  lcm = a[0]
  for i in range(1,n):
    big,sml = a[i],lcm
    while sml != 0:
      big,sml = sml,big%sml
    lcm *= a[i] // big
  #print(lcm)
  ans = m // (2*lcm)
  if m % (2*lcm) >= lcm:
    ans += 1
  print(ans)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
# if not sum(e & 1 for e in a) in [0, n]:
#     print(0)
#     exit(0)
lcm = 1
for e in a:
    e //= 2
    lcm *= e // gcd(lcm, e)
    if lcm > m: break
res = (1 + m // lcm) // 2
print(res)

Submission status: Wrong Answer

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

#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = list( map( lambda x: x//2, A))
    T = 1
    L = 1
    for i in range(N):
#        L = A[i]*L//gcd(L, A[i])
        T = T*B[i]//gcd(T, B[i])
        
        # if T//B[i]%2 == 0:
        #     T *= 2
        if T > M:
            print(0)
            return
    for i in range(N):
        if T//B[i]%2 == 0:
            T *= 2
            break
    K = T
    if T%2 == 1:
        K *= 2
    
    print( (M-T)//K + 1)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    return gcd(b % a, a)


def lcd(a, b):
    g = gcd(a, b)
    return a * b // g


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

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

l = 1
for e in A:
    l = lcd(l, e)

tmp = m // l
ans = tmp // 2 + tmp % 2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = 1
flag = 0
for i in range(N):
    gcd = fractions.gcd(A[i] // 2, lcm_half)
    lcm_half = (lcm_half * (A[i]) // 2) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)

Submission status: Wrong Answer

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

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

GCD = 1
for i in range(len(a)):
	GCD = GCD*a[i] // gcd(GCD,a[i])
	
A = (2*m) // GCD
if A%2 == 1:
	A+=1

print(A//2)

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()))
a = A[0]
for i in range(1,N):
    a = gcd(a,A[i])
B = list(set(A))
b = a
for x in B:
    b *= x//a
k = (M-b//2)//b
print(k+1)

Submission status: Wrong Answer

Solution code:


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

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

ans = 0
for X in range(1, M+1):
    flg = False
    mitasu = []
    for ak in A:
        p = X/ak - 0.5
        if p.is_integer() and p > 0:
            flg = True
        else:
            flg = False
            break
    
    if flg:
        ans += 1
        flg = False

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=[i//2 for i in set(list(map(int,input().split())))]
l=1
for i in a:
    l=l*i//gcd(i,l)
    if m<l:
        print(0)
        break
else:
    print((m//l+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

n_lcm = lcm_list(a)
h_lcm = n_lcm // 2
if h_lcm > m:
    print(0)
else:
    print((m - h_lcm)//n_lcm + 1)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = [x for x in map(int, input().split())]
lst = []

for i in range(n):
  x = 0
  p = 0
  while x <= m:
    x = int(a[i]*(p+0.5))
    if x > m:
      break
    lst.append(x)
    p += 1

res = []
for i in lst:
  if lst.count(i) == n:
    res.append(i)
print(len(res)//2)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
# a = list(set([int(i)//2 for i in input().split()]))
a = list(set(int(i)//2 for i in input().split()))
c = 1
for n in a:
    c *= n
print(M//c - M//(c*2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


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


# temp = reduce(lcm, y, 1)
temp = lcm(max(y), min(y))

ans = (m // temp) / 2

# print(ans)
ans = math.ceil(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(a, b):
  return (a * b) // gcd(a, b)
 
 
n, m = map(int, input().split())
a = list(set(map(int, input().split())))
n = len(a)
a = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
  if all_lcm > m:
    exit(print(0))
m -= m % all_lcm
if not m % 2:
  m -= all_lcm
print(m // all_lcm // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

read = sys.stdin.read
N, M, *a = map(int, read().split())
a = list(set(a))

lcm = a[0]
for i in a:
    g = gcd(lcm, i)
    lcm = lcm * i // g
    if lcm > M:
        print(0)
        exit()

lcm //= 2
if M < lcm:
    print(0)
else:
    print((M - lcm) // (lcm * 2) + 1)

Submission status: Wrong Answer

Solution code:
n,m = (int(i) for i in input().split())
a = [int(i)//2 for i in input().split()]
a.sort()
d = a[0]
for i in range(n):
  if a[i]%2 == 0:
    print(0)
    exit()
for i in range(1,n):
  x = d
  y = a[i]
  if x<y:
    temp = x
    x = y
    y = temp
  r = x%y
  while r>0:
    x = y
    y = r
    r = x%y
  d = d*a[i] // y
ans = (m+d-1)//(2*d)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
ans=a[0]
for i in range(1,n):
    ans = ans * a[i] // gcd(ans, a[i])
    if ans//2>m:
        print(0)
        quit()
ans//=2
if ans>m:
    print(0)
else:
    print((m-ans)//(ans*2)+1)

Submission status: Wrong Answer

Solution code:
import functools
import fractions
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
N,M=map(int,input().split())
A=list(map(int,input().split()))
LCM=functools.reduce(lcm,A)
HLCM=LCM//2
Y=M//HLCM
if Y%2==0:
    print(Y//2)
else:
    print((Y+1)//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
from fractions import gcd
from functools import reduce
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template

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

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

def main():
    n, m = mi()
    a = lmi()
    cnt = 0
    while(True):
        if all(x % 2 == 0 for x in a):
            cnt += 1
            a = list(map(lambda x: x // 2, a))
        else:
            break
    c = pow(2, cnt)
    for i in range(n):
        if a[i] % 2 == 0:
            print(0)
            exit()
    now = 1
    for i in range(n):
        now = lcm_base(now, a[i])
        if(now >= c * m):
            print(0)
            exit()
    la = now
    x = m // la
    print((x + 1) // c)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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


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

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

def lcm_list(l):
    return reduce(lcm, l, 1)

a = lcm_list(A)
b = a * 2

print(M//a - M//b)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

A=list(map(int,input().split()))
B=list(map(lambda x: x//2, A))

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B[i+1]=B[i]*B[i+1]//(fractions.gcd(B[i],B[i+1]))


if M<B[-1]:
    print(0)
else:
    print((M-B[-1])//A[-1]+1)

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = 1
for a in A:
    all_lcm = lcm(all_lcm, a)

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

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
a = list(map(int, input().split()))
k=0
t=a[0]
while 1:
    if t%2==0:
        k+=1
        t//=2
    else:
        break
K=2**k
from fractions import gcd
l=t
for i in a:
    if i%K==0 and (i//K)%2==1:
        t=i//K
        l=l*t//gcd(l,t)
    else:
        print(0)
        break
else:
    print((M-l)//(2*l)+1)