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:
from fractions import gcd


def main():
    N, M = map(int, input().split()[:2])
    A = sorted(set(map(int, input().split())))
    N = len(A)

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

    if lcm > M:
        print(0)
    else:
        t = M // lcm
        print(t - t // 2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def gcd(a, b): #a,bの最大公約数
    while b:
        a, b = b, a % b
    return a
def lcm(a, b): #a,bの最小公倍数
    return a * b // gcd (a, b)

A = list(set(A)) 

# すべての数の最小公倍数
all_lcm = 1
for a in A:
  all_lcm = lcm(all_lcm, a)
  
# 条件式を満たす最大の少数p
plist = [(M/a - 0.5) for a in A]

if all_lcm > M:
  print(0)
elif min(plist) < 1:
  # 条件を満たす整数Xが存在しないAがある場合は個数0
  print(0)
else:
  # print(plist)
  plist = [int(p) for p in plist]  # それぞれこの個数分ある
  print(int((M)/all_lcm - 0.5)+1)
  # print(all_lcm)
  # print(plist)

Submission status: Wrong Answer

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

import functools
import fractions

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

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

l = lcm_list(A)

print(m//(l//2) - m//l)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

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

ans = 0
ans_bool = False

for i in li:
  if lcm % i == 0 and ((lcm // i) % 2) == 1:
    ans_bool = True
  else:
    ans_bool = False
    break

ans = 2 * m // lcm
ans = math.ceil(ans / 2)

print(ans)

Submission status: Wrong Answer

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

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

def LCM(arr, n): 
    res = arr[0]
    for i in range(1, n):
        res = lcm(res, arr[i])
  
    return res; 
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
AH = [a//2 for a in A]

D = LCM(A, N)
O = D // 2
print(max(0, (M-O) // D + ((M-O)%D != 0)))

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a = list(set(list(map(int, input().split()))))
ans = a[0] / 2
torf = "f"
for i in range(1, len(a)):
    ans = ans * a[i]/2 // fractions.gcd(ans, a[i]/2)
for j in range(len(a)):
    if a[j]/2 % 2 == 0:
        print(int(m//ans))
        torf = "t"
if torf == "f":
    print(int(m//ans - (m//(ans*2))))

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))
n,m = words(int)
xs = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

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

lcms = 1
plus = 1
odd = (xs[0]//2) % 2 == 1
ans = True
for x in xs:
    if plus % 2 != (x//2)%2:
        ans = False
        break
    lcms = lcm(lcms,x)
    plus = lcm(plus, x//2)

#print(lcms,plus)
if ans:
    print((m + plus) // (lcms))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=list(set(A))
A=np.array(A)
cnt=0

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

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

while sum(A%2)==0:
    cnt+=1
    A//=2
if np.sum(A%2)!=len(A):
    ans=0
else:
  maxbai=A[-1]
  for i in range(len(A)):
    maxbai=lcm(A[-i-1],maxbai)
  for i in range(cnt):
    m=m//2
  ans=m//maxbai+1
print(ans)

Submission status: Wrong Answer

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

B = set(A)
C = list(B)
C.sort(reverse=True)
buf1 = buf2 = ""

for p in range(1, 10**5):
    flag = True

    X = C[0] * (p + 0.5)
    if X > M:
        break

    for c in C:
        if ((X / c) - 0.5).is_integer():
            continue
        else:
            flag = False
            break
    
    if flag:
        if buf1 == "":
            buf1 = X
        else:
            buf2 = X
            break

if buf1 == "":
    print(0)
elif buf1 != "" and buf2 == "":
    print(1)
else:
    print(int((M + buf1) // (buf2 - buf1)))

Submission status: Wrong Answer

Solution code:
from itertools import permutations as perm
from functools import reduce 
from fractions import gcd
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2, input().split()))
if 1 in a:
    a.remove(1)
if len(a) == 0:
    print(m)
    exit()
g = reduce(gcd, a)
if len(a) > 1 and sum([i % 2 == 0 for i in a]) and g == 1:
    print(0)
    exit()
# print(g)
l = g
for i in a:
    l *= i // g
from math import ceil
print(ceil(m // l / 2))

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())
a = list(set(a))

for x in range(len(a)):
  if a[x] % 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 main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    from bisect import bisect_right as br
    c=br(A,A[-1]//2)
    for a in A:
        kou=a*kou//gcd(a,kou)
    for a in range(min(c+1,n)):
        if (kou//A[a])%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions
from functools import reduce

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

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

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a_d = a // 2

ans = m / lcm(*a_d) / 2
if ans.is_integer():
    ans = m // lcm(*a_d) // 2 - 1
    print(int(ans))
else:
    ans = round(m / lcm(*a_d) / 2)
    print(int(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
    if k > M*2:
        print(0)
        exit(0)
    k = int(k)
ans = (M - (k // 2)) // k

if M >= (k // 2):
    flag = True
    for i in range(N):
        if ((k // 2) // a[i]) % 2 == 0:
            flag = False
            break
    if flag:
        ans += 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
def lcm(x, y):
    """
    xとyの最小公倍数を求める。

    Parameters
    ----------
    x,y : int
        自然数

    Returns
    -------
        最小公倍数：int

    """
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
lc=[]
ans=0
if n==1:
    ans=(m+a[0])//(a[0]//2)
    if ans%2==1:
        ans//=2
        ans+=1
    else:
        ans//=2
    print(ans)
    exit()
# for i in range(n):
#     b.append(a[i]//2)
# print(a)
for i in range(n):
    a[i]//=2
# print(a)
t=0
for i in range(n-1):
    if i==0:
        t=lcm(a[i],a[i+1])
        lc.append(t)
    elif i!=0:
        t=lcm(lc[i-1],a[i+1])
        # t=min(lc[i-1],t)
        lc.append(t)

if len(lc)==0:
    print(0)
    exit()


ans=(m+max(a))//max(lc)
if ans%2==1:
    ans//=2
    ans+=1
else:
    ans//=2
print(ans)

Submission status: Wrong Answer

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

B = set(A)
C = list(B)
C.sort(reverse=True)
buf1 = buf2 = ""

for p in range(1, 10**5):
    flag = True

    X = C[0] * (p + 0.5)
    if X > M:
        break

    for c in C:
        if ((X / c) - 0.5).is_integer():
            continue
        else:
            flag = False
            break
    
    if flag:
        if buf1 == "":
            buf1 = X
        else:
            buf2 = X
            break

if buf1 == "":
    print(0)
elif buf1 != "" and buf2 == "":
    print(1)
else:
    print(int((M - buf1) // (buf2 - buf1)) + 1)

Submission status: Wrong Answer

Solution code:
import functools
N,M = map(int,input().split())
a = tuple(map(int,input().split()))

def scm(i):
    l = []
    p = 1
    while(int(i*p + i/2) <= M):
        l.append(int(i*p + i/2))
        p += 1
    return l

def common_strip(list1,list2):
    return set(list1) & set(list2)

ans = list(functools.reduce(lambda x,y:common_strip(x,y) , list(map(scm,a))))

print(len(ans))

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(*numbers):
    return reduce(lcm_base, numbers, 1)
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

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

for i in range(N):
        '''
        a = factorization(A[i]) 
        B.append(A[i] // (2**a[0][1]))
        '''
        while A[i] % 2 == 0:
                A[i] //= 2

a = lcm(*A)
#print(a)

if a > M or a==1:
        print(0)
        exit(0)
'''
for i in range(a,M+1,a*2):
    #print(i)
    i = float(i)
    flag = 0
    for j in A:
        #print((i / j)-0.5)
        if ((i / j)-0.5).is_integer() == False:
            flag = 1
    if flag == 0 and 0 <= (i / j)-0.5:
        break
'''
print(int((M-a) // (a*2) + 1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
m -=ans//2
print(m//ans+1 if m//ans>=1 else 0)

Submission status: Wrong Answer

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

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

N, M = map(int,input().split())
A = list(map(int,input().split()))
cnt = M
for i in range(N):
  if A[i]%2 == 0:
    A[i] = A[i]//2
  else:
    cnt = 0
lcm = A[0]
for i in range(1, N):
  lcm = lcm*A[i]//gcd(lcm, A[i])

print(min(cnt, 1+(M-lcm)//(2*lcm)))

Submission status: Wrong Answer

Solution code:
import fractions as math
n,m = map(int,input().split())
lst1 = list(map(int,input().split()))
lst1 = list(set(lst1))
ans = 0
lst1.sort(reverse=True)
for i in range(len(lst1)):
    lst1[i] //= 2
#最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = a*(l[i])//math.gcd(a,l[i])
    return a

syoko = lcmlist(lst1)

if syoko > m:
    print(0)
    exit()
ans += 1

m -= syoko
ans += m//(syoko*2)

print(ans)

Submission status: Wrong Answer

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


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


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

M *= 2

if M == 2:
    if len(a) == 1:
        for i in a:
            if i == 2:
                print(0)
                exit()

for i, b in enumerate(a):
    if i == 0:
        v = b
    v = lcm(v, b)
    if v > M:
        print(0)
        exit()
print((M // v + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
import numpy as np


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


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


def main():
    N, M = map(int, input().split())
    numbers = set(map(int, input().split()))
    numbers = np.array(list(numbers))
    numbers = numbers // 2

    lcm = lcm_list(numbers)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans=0
n,m=map(int,input().split())
a=list(map(int,input().split()))
lcm=a[0]//2
flag=0
f=1
if(lcm&1):
	flag=1
for i in range(n):
	if(flag^((a[i]//2)&1)):
		f=0
		break
	lcm=((a[i]//2)*lcm)//(gcd(a[i]//2,lcm))
	if(lcm>m):
		f=0
		break
if(f):
	ans=(m//(2*lcm))+1
print(ans)

Submission status: Wrong Answer

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

def lcm(n, m): 
    g = gcd(n, m)
    return n * m // g

N, M = map(int, input().split())
A = list(map(int, input().split()))
res = 1
for i in range(0, N):
    res = lcm(res, A[i])

if res > M: print(0)
else: print(1 + (M-res//2) // res)

Submission status: Wrong Answer

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

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

ans = (M//ans - 1)//2 + 1 if ans > 0 else 0
asn = ans if ans > 0 else 0
print(ans)

Submission status: Wrong Answer

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

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

def LCM(arr, n): 
    res = arr[0]
    for i in range(1, n):
        res = lcm(res, arr[i])
  
    return res; 
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
AH = [a//2 for a in A]

D = LCM(A, N)
O = D // 2
print(max(0, (M-O) // D + 1))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random
import fractions


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def good(A, N):
    # A = sorted(A)
    ans = A[0]
    # for i in range(1, N):
    #     ans = fractions.gcd(A[i], ans)
    for i in range(1, N):
        ans = ans * A[i] // fractions.gcd(ans, A[i])
    return ans


def main():
    N, M = MI()
    a = LI()
    n = good(a, N)

    # print(n, n // 2, M)
    if n // 2 > M:
        print(0)
    else:
        t = (2 * M // n)
        if t % 2 == 0:
            t -= 1
        print(t // 2 + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import fractions
bbn=1000000007
	
#+++++

def gcd(a,b):
	return fractions.gcd(a,b)
	
def lem(a,b):
	return (a*b)//gcd(a,b)
		
def main():
	n, m = map(int, input().split())
	al=list(map(int, input().split()))
	ii=al[0]//2
	ll=ii
	for v in al[1:]:
		ll=lem(ll,v//2)
		
	if ll%2==0:
		return 0
		
	ret=((m//ll)+1)//2
	
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

import numpy as np
import fractions
A=np.array(A)

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

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

if mm%2==0:
    ans=0
else:
    ans=int((M/mm-1)//2)+1


print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        a = list(map(int, input().split()))

        a.sort()
        d = a[0]
        for i in range(1, N):
            d = self.lcm(d, a[i])
            if d > M:
                print(0)
                exit()

        print(M // d + 1)

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

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


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
saisyou = lcm(*A)
kosuu = math.ceil(M/saisyou)
print(kosuu)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]
    
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
flag = False
b = lcm(a)
#while flag == False:
#    flag = True
#    for i in range(N):
#        if (b // a[i]) % 2 == 0:
#            flag = False
#    if flag == False:
#        b += b
if M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

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
if len(set(a))==1 and a[0]%2==0:
    print(int(M//(a[0]*3)))
    exit()
def lcm(n,m):
    if m%n == 0:
        return n
    else:
        n,m=m%n,n
        return lcm(n,m)
def gcd(n,m):
    return n*m//lcm(n,m)

def end():
    print(0)
    exit()
even_flag = False
odd_flag = False
ans = a[0]
if a[0]%2 == 0:
    tmp = a[0]
    even_flag = True
else:
    tmp = 0
    odd_flag = True

for i in a[1:]:
    if i%2:
        odd_flag = True
    if not i%2:
        even_flag = True
    if odd_flag and even_flag:
        end()
    if tmp and not i%2 and not tmp == i:
        end()
    elif not tmp and i%2:
        tmp = i

    ans = gcd(ans,i)
if ans == 0:
    print(0)
elif ans == 1:
    print(M//ans-M//(ans*2)-1)
else:
    print(M//ans - M//(ans*2))

Submission status: Wrong Answer

Solution code:
#!python3

def iim():
    return map(int, input().rstrip().split())

def resolve():
    N, M = iim()
    a = list(iim())

    aa = 1
    for x in set(a):
        if x & 3 == 0:
            print(0)
            return
        aa *= x

    aa //= 2
    print(M//aa + 1)


def resolve1():
    a = [6, 36, 36]

    b = []
    for x in a:
        b.append(set(x * (i+.5) for i in range(100)))


    print(sorted(b[0] & b[1] & b[2]))

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import math

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

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

pres = []
num = 1;
den = -1

for e in a:
    if(den == -1):
        den = e//2
    else:
        den = gcd(den,e//2)
    if((e//2) not in pres):
        num *= e//2
        pres.append(e//2)

lcm = num//den

terms = m//lcm

ans = (terms+1)//2

for e in a:
    if((lcm//(e//2))%2==0):
        ans = 0
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def X_calculus(a,p):
    return a*p+0.5*a

N,M = map(int,input().split())
lst = list(map(int,input().split()))
A = [num for num in lst if num%2 == 0]
Seen = []
p = 0
Res = 0
for k in range(len(A)):
    while X_calculus(A[k],p) <= M:
        print(X_calculus(A[k],p))
        if X_calculus(A[k],p) in Seen:
            Res += 1
        Seen.append(X_calculus(A[k],p))
        p = p+1
    p = 0
print(Res)

Submission status: Wrong Answer

Solution code:
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)

    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z

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

[N,M] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

skoubaisu = 1
for x in a:
    skoubaisu = lcm(skoubaisu,x)

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

Submission status: Wrong Answer

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

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

a=list(set(a))
m*=len(a)
sa=1
p=0
for i in range(len(a)):
    m=m/a[i]
if m<1:
    print("0")
else:
    print(int(m)+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
A=list(map(int,input().split()))
def gcd(x1,x2):
    a=min(x1,x2)
    b=max(x1,x2)%a
    while not b==0:
        ta=b
        b=a%b
        a=ta
    return a

def lca(l):
    lc=1
    for i in range(len(l)):
      g=gcd(lc,l[i])
      lc=lc*l[i]//g
    return lc

end=False
for i in range(N):
    A[i]=A[i]//2
    if A[i]%2==0:
        end=True
        break
if end:
    print(0)
else:
    l=lca(A)
    ans=0
    m=M-l
    if m>=0:
        ans+=1
        ans+=(m//(l*2))
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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

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

    print(M // l // -2 * -1)


main()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline

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

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

flag = False
even = False
odd = False
for value in b:
    if value % 2 == 0:
        if odd == True:
            flag = True
        even = True
    else:
        if even == True:
            flag = True
        odd = True
if flag:
    print(0)
    exit()

x = b[0]
for i in range(1, len(b)):
    x = (x * b[i]) // gcd(x, b[i])

lcm = x

q = M // lcm

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y):
    return (x // gcd(x, y))*y
def gcd_list(numbers):
    res = 1
    for n in numbers:
        res = lcm(n, res)
        if res>M:
            return -1
    return res


N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = max(a)
A = gcd_list(a)
a = list(map(lambda x:x//2, a))
B = gcd_list(a)
a, b = M//A, M//B
if A == -1:
    a = 0
if B == -1:
    b = 0
if aa == A and aa<=M:
    print(b-a-1)
else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd #なおす
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in a]

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

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

div_count = 0
while True:
    all_odd = True
    for i in range(len(a)):
        a[i]//=2
        if a[i]%2==0:
            all_odd = False
        if i>1:
            if a[i-1]%2!=a[i]%2:
                print(0)
                sys.exit()
    if all_odd is True:
        break
    else:
        div_count+=1

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

if div_count>0:
    _min*=2*div_count
print(m//_min-(m//_min)//2)

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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

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

n, m = map(int, input().split())
a_list = sorted(set(map(int, input().split())))
prod = 1
for a in a_list:
    if a % 4 == 0:
        print(0)
        exit(0)
    prod *= a // 2
lcm = lcm_list(a_list)
if prod > m:
    print(0)
else:
    print((m - prod) // lcm + 1)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd #なおす
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in a]

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)
def lcm(a,n,m):
    ans = a[0]
    for i in range(1,n):
        ans = (ans * a[i])/(gcd(a[i],ans))
        if ans > 10**32:
            return -1
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)


start = l//2    
# print(start)
ans = (m - (start))//l
# print(ans)
if ans < 0 or l==-1:
    print(0)
else:
    ans += 1
    print( round(ans) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def lcm_list(numbers, N):

    ans = numbers[0]

    for i in range(1,N):
        ans = lcm_base(ans,numbers[i])

    return ans

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

a_lcm = lcm_list(A_n,N)
ans = 0
interval = a_lcm//2

amari = M // interval

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list(map(int, input().split()))

Aset = list(set(A))
res = []
for k in range(1,M):
    flag = True
    for a in Aset:
        if not(((2*k) % a == 0) and k % 2 != 0):
                        
            flag = False
    if flag:
        res.append(k)

print(len(res))

Submission status: Wrong Answer

Solution code:

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    from bisect import bisect_right as br
    c=br(A,A[-1]//2)
    for a in range(c+1):
        kou=A[a]*kou//gcd(A[a],kou)
        if (kou//A[a])%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

import math
import fractions
from functools import reduce

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


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


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


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


def resolve():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    L = lcm_list(a_list)
    if any([(L // a) % 2 == 0 for a in a_list]):
        print(0)
        return
    else:
        print(M // L + 1)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

alist = list(map(int,input().split(' ')))
alist = [i // 2  for i in alist]


from fractions import gcd

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

def get_lcm_for(your_list):
    return reduce(lambda x, y: getLCM(x, y), your_list)

lcmr = get_lcm_for(alist)

result = (m + lcmr)//(lcmr*2)


print(result)

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)