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: Runtime Error

Solution code:
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    if len(A) >= 1:
        for a in A:
            a_lcm = lcm(a_, a)
            a_ = a_lcm
    else:
        a_lcm = a_ 
    for i in A_:
        if a_lcm / 2 % i != 0:
            continue
        else:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % i != 0:
            continue
        else:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# import sys
# sys.setrecursionlimit(10**7)
import copy

from math import gcd

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % i == 0:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % i == 0:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % i == 0:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % 2 == 0:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    for i in A_:
        if a_lcm / 2 % i == 0:
            print(0)
            exit()    
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = list(set([int(x) for x in input().split()]))
    a_ = A[0]
    for a in A[1:]:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_ = A[0]
    for a in A[1:]:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# import sys
# sys.setrecursionlimit(10**7)

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_ = 1
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    if a_lcm / 2 > m:
        print(0)
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
def lcm_base(x, y):
  return (x * y) // math.gcd(x, y)

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

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

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

cnt_common = -1
for i in a:
  cnt = 0
  while i % 2 == 0:
    i = i//2
    cnt += 1
  if cnt_common == -1:
    cnt_common = cnt
    continue
  if cnt_common != cnt:
    nothing = True
    break

b=lcm_list(a)
if nothing:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))

Submission status: Runtime Error

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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    ta=max(t//2,lcm1)
    tb=min(t//2,lcm1)
    if ta!=tb and ta//tb%2==0:
        lcm1=0
        lcm2=0
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)


if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)

Submission status: Runtime Error

Solution code:
from math 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 evencount(n):
  cnt=0
  while n%2==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[i]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Submission status: Runtime Error

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 evencount(n):
  cnt=0
  while n&1==0:
    cnt+=1
    i>>1
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
if all(set([evencount(i) for i in a])):
  for i in range(n):
    a[i]//=2
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Submission status: Runtime Error

Solution code:
import math
import itertools
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

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

#k,x = list(list(map(int, input().split())))
n,m = list(list(map(int, input().split())))
a = list(list(map(int, input().split())))
c =lcm(*a)
c = int(c/2)
ans = 0
for i in range (c,m+1,c):
    count = 0
    for j in a:
        if (i/j)%2 ==1:
            count+=1
    if count == n:
        c = i
        ans =1
        break

ans = (m+i)//(i)

Submission status: Runtime Error

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 1000000000
6 6 2 6 2
'''

def solve(l,m):
	l = list(set(l))
	n = len(l)
	g = l[0]
	p = l[0]
	if(2*m < max(l)):
		return 0
	for i in range(1,n):
		g = gcd(g,l[i])
		p *= l[i]
	l = p//g
	if(l > m):
		return 0
	t = l // 2
	return m//t - m//l

N,M = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,M)
print(ans)

Submission status: Runtime Error

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

ma = max(A)
mp = [0] * (m+1)
xma= (ma//2) * (2*m //ma)

for a in A:
    for p in range(int(ma/2/a -0.5),int(xma /a-0.5)+1):
        mp[a*(2*p+1)//2] +=1

print(mp.count(n))

Submission status: Runtime Error

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

mp = [0] * (m+1)

for a in A:
    for p in range(1,int((m/a)-0.5)+1):
        mp[int(a*(p+0.5) + 0.1)] +=1

print(mp.count(n))

Submission status: Runtime Error

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

mp = [0] * (m+1)

for a in A:
    for p in range(int((m//a))):
        mp[int(a*(p+0.5) + 0.1)] +=1

print(mp.count(n))

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.read
from math import gcd

def main():
    n, m, *a = map(int, read().split())
    d = [0] * n
    for i, ae in enumerate(a):
        t1 = 0
        while ae > 0:
            if ae % 2 == 0:
                t1 += 1
                ae /= 2
            else:
                break
        d[i] = t1
    d_c = [de == d[0] for de in d]
    if not all(d_c):
        print(0)
        sys.exit()
    div = 2**d[0]
    a2 = [ae // div for ae in a]
    m /= div
    g = (a2[0] * a2[1]) // gcd(a2[0], a2[1])
    for i1 in range(1, n):
        g = (g * a2[i1]) // gcd(g, a2[i1])
        if g > m:
            print(0)
            sys.exit()

    r = m // g + 1
    print(int(r))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in a:
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A_r=sorted(A,reverse=True)
def judge(n):
    Ai=0
    j=0
    while(Ai<len(A_r) and j==0):
        if (n-A_r[Ai]//2)%A_r[Ai]==0:
            j+=0
        else:
            j+=1
        Ai+=1
    if j==0:
        return True
    else:
        return False
jud=False
while (jud ==(False) and aa<=M):
    aa=A_r[0]/2
    jud=judge(aa)
    aa+=A_r[0]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm=lcm_list(A_r)
if jud==(False):
    print(int(0))
else:
    print(int((M-(aa-A_r[0]))//lcm+1))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A_r=sorted(A,reverse=True)
def judge(n):
    Ai=0
    j=0
    while(Ai<len(A_r) and j==0):
        if (n-A_r[Ai]//2)%A_r[Ai]==0:
            j+=0
        else:
            j+=1
        Ai+=1
    if j==0:
        return True
    else:
        return False
jud=(False)
while (jud ==(False) and aa<=M):
    aa=A_r[0]/2
    jud=judge(aa)
    aa+=A_r[0]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm=lcm_list(A_r)
if jud==(False):
    print(0)
else:
    print((M-(aa-A_r[0]))//lcm+1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A_r=sorted(A,reverse=True)
def judge(n):
    Ai=0
    j=0
    while(Ai<len(A_r) and j==0):
        if (n-A_r[Ai]//2)%A_r[Ai]==0:
            j+=0
        else:
            j+=1
        Ai+=1
    if j==0:
        return True
    else:
        return False
jud=(False)
while (jud ==(False) and aa<=M):
    aa=A_r[0]/2
    jud=judge(aa)
    aa+=A_r[0]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm=lcm_list(A_r)
if jud==(False):
    print(round(0))
else:
    print(round((M-(aa-A_r[0]))//lcm+1))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A_r=sorted(A,reverse=True)
def judge(n):
    Ai=0
    j=0
    while(Ai<len(A_r) and j==0):
        if (n-A_r[Ai]//2)%A_r[Ai]==0:
            j+=0
        else:
            j+=1
        Ai+=1
    if j==0:
        return True
    else:
        return False
jud=(False)
while (jud ==(False) and aa<=M):
    aa=A_r[0]/2
    jud=judge(aa)
    aa+=A_r[0]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm=lcm_list(A_r)
if jud==(False):
    print(int(0))
else:
    print(int((M-(aa-A_r[0]))//lcm+1))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from math import gcd

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


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 != 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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

a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

if n==1:
    curr_lcm*=2
    lcm_cnt = (m-curr_lcm//2)//curr_lcm
else:

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=test*k//math.gcd(test,k)
if l==0:
  k=test*c/2

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=lcm_base(test, k)
if l==0:
  k=int(test*c/2+0.5)
  print(M//k//2 + M//k%2)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
d=2**c

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
for i in np.arange(N-1):
  if A[i+1]%d!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(d*2)==0:
    print(0)
    l=1
    break
  else:
    k=int(A[i+1]/d+0.5)
    test=lcm_base(test, k)
if l==0:
  k=int(test*d/2+0.5)
  print(M//k//2 + M//k%2)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
d=2**c
 
for i in np.arange(N-1):
  if A[i+1]%d!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(d*2)==0:
    print(0)
    l=1
    break
  else:
    k=int(A[i+1]/d+0.5)
    test=int(test*k/math.gcd(test,k)+0.5)
if l==0:
  k=int(test*d/2+0.5)
  print(M//k//2 + M//k%2)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
 
for i in np.arange(N-1):
  if A[i+1]%(2**c)!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(2**(c+1))==0:
    print(0)
    l=1
    break
  else:
    k=int(A[i+1]/(2**c)+0.5)
    test=int(test*k/math.gcd(test,k)+0.5)
if l==0:
  k=test*(2**(c-1))
  print(M//k//2 + M//k%2)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
 
for i in np.arange(N-1):
  if A[i+1]%(2**c)!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(2**(c+1))==0:
    print(0)
    l=1
    break
  else:
    test=int(test*int(A[i+1]/(2**c)+0.5)/math.gcd(test,int(A[i+1]/(2**c)+0.5))+0.5)
if l==0:
  print(M//(test*(2**(c-1)))//2 + M//(test*(2**(c-1)))%2)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
from numba import jit
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2)
  c+=1
 
for i in np.arange(N-1):
  if A[i+1]%(2**c)!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(2**(c+1))==0:
    print(0)
    l=1
    break
  else:
    test=int(test*A[i+1]/(2**c)/math.gcd(test,int(A[i+1]/(2**c)+0.5))+0.5)
if l==0:
  print(M//(test*(2**(c-1)))//2 + M//(test*(2**(c-1)))%2)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
import fractions

N,M = list(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)

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

l = int(lcm_list(A)/2)
for i in range(N):
    if A[i] % 2 == 0:
        print(0)
        exit
print(math.floor((2*M-l)/(2*l))+1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

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

l = lcm_list(A)
print(math.floor((2*M-l)/(2*l))+1)

Submission status: Runtime Error

Solution code:
import math
import fractions
from functools import reduce

n, m = map(int,input().split())
a = list(map(int,input().split()))
a = [t // 2 for t in a]#リストの要素すべてを2で割る

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

def lcm_list(numbers): #最小公倍数を求める
    return reduce(lcm_base, numbers, 1)

def num_dev2(x):
    return bin(x)[::-1].find("1") #２で割り切れる回数を確認

lcm = lcm_list(a)
q = m//lcm #mは最小公倍数で何回割れるか

count = 0
dev2 = num_dev2(a[0])
for i in range(1,n):
    if dev2 != num_dev2(a[i]):#リストのすべての要素の２で割れる回数は等しいか
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

Submission status: Runtime Error

Solution code:
import math
import fractions
from functools import reduce

n, m = map(int,input().split())
a = list(map(int,input().split()))
a = [x // 2 for x in a]#リストの要素すべてを2で割る

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

def lcm_list(numbers): #最小公倍数を求める
    return reduce(lcm_base, numbers, 1)

def num_dev2(x):
    return bin(x)[::-1].find("1") #２で割り切れる回数を確認

lcm = lcm_list(a)
q = m #lcm,mは最小公倍数で何回割れるか

count = 0
dev2 = num_dev2(a[0])
for i in range(1,n):
    if dev2 != num_dev2(a[i]):#リストのすべての要素の２で割れる回数は等しいか
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

Submission status: Runtime Error

Solution code:
from math import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = lcm(ans,i)
for i in a:
    if (ans//i) % 2 == 0:
        print(0)
        exit()
print(((m//(ans//2))+1)//2)

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

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

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

l = 1
for i in range(n):
    a[i] //= 2
    l = lcm(a[i], l)

flg = True
for x in a:
    if (l / x) % 2 == 0:
        flg = False
        continue

if flg:
    print(m // l - m // (l * 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
# from fractions import gcd
from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def run():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


run()

Submission status: Runtime Error

Solution code:
# from fractions import gcd
from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def main():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


main()

Submission status: Runtime Error

Solution code:
import functools
import sys

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

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    a = a[i]
    while a % 2 == 0:
        a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


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

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Submission status: Runtime Error

Solution code:
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))
a = set(a)

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    a = a[i]
    while a % 2 == 0:
        a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


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

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Submission status: Runtime Error

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

def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    A = list(map(lambda x:x//2, A))
    # 全aiについて、2で割れる回数が同じである必要がある
    # L=LCM(a0,a1,a2,...)としてL,3L,5L...<=Mの個数が答え
    while(A[0]%2==0):
        A = [a//2 for a in A]
    for a in A:
        if a%2==0:
            print(0)
            return

    L = lcm(A[0],A[1])
    for i in range(2,):
        L = lcm(L,A[i])

    print(ceil(M//L/2))

main()

Submission status: Runtime Error

Solution code:
import functools
import sys

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


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

    return gcd(y % x, x)


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)
ans = 0
a = 1
while True:
    if lc * a <= m:
        ans += 1
        a += 2
    else:
        break

print(ans)

Submission status: Runtime Error

Solution code:
from math import ceil,gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
    
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    A = list(map(lambda x:x//2, A))
    # 全aiについて、2で割れる回数が同じである必要がある
    # L=LCM(a0,a1,a2,...)としてL,3L,5L...<=Mの個数が答え
    while(A[0]%2==0):
        A = [a//2 for a in A]
    for a in A:
        if a%2==0:
            print(0)
            return

    L = lcm(A[0],A[1])
    for i in range(2,):
        L = lcm(L,A[i])

    print(ceil(M//L/2))

main()

Submission status: Runtime Error

Solution code:
import functools
import sys

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


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

    return gcd(y % x, x)


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)
# ans = 0
# a = 1
# while True:
#     if lc * a <= m:
#         ans += 1
#         a += 2
#     else:
#         break
#
# print(ans)

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Submission status: Runtime Error

Solution code:
import fractions
import functools

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


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / fractions.gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)

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