Problem:


Score : 400 points

Problem Statement

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

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

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

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

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

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

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

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

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from copy import deepcopy
n,m = map(int,input().split())
A = list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)
Acopy = deepcopy(A)
flag = -1
for i in range(n):
  cnt = 0
  while True:
    if Acopy[i] % 2 == 1:
      break
    else:
      Acopy[i] //= 2
      cnt += 1
  if i == 0:
    flag = cnt
  else:
    if flag != cnt:
      print(0)
      break
else:
  A = [a//2 for a in A]
  lcm = lcm_list(A)
  print(math.ceil(m/lcm/2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from copy import deepcopy
n,m = map(int,input().split())
A = list(map(int,input().split()))
A = [a for a in A]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)
Acopy = deepcopy(A)
flag = -1
for i in range(n):
  cnt = 0
  while True:
    if Acopy[i] % 2 == 1:
      break
    else:
      Acopy[i] //= 2
      cnt += 1
  if i == 0:
    flag = cnt
  else:
    if flag != cnt:
      print(0)
      break
else:
  lcm = lcm_list(A)
  print(math.ceil(m/lcm))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
n,m = map(int,input().split())
A = list(map(int,input().split()))
A = [a//2 for a in A]
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)
lcm = lcm_list(A)
ans = 0
print(math.ceil(m//lcm/2))

Submission status: Wrong Answer

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()))
l = [0] * n
for i in range(n):
    while a[i] % 2 == 0:
        a[i] //= 2
        l[i] += 1
    if i > 0 and l[i] != l[i - 1]:
        print(0)
        exit(0)
res = 1
for i in range(n):
    res = lcm(res, a[i])
print(m // res - m // (res * 2))

Submission status: Wrong Answer

Solution code:
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


def main():
    N, M = in_nn()
    a = in_nl()

    lcm = 1
    for i in range(N):
        lcm = LCM(lcm, a[i] // 2)
        if lcm > M * 10:
            print(0)
            exit()

    q = M // lcm
    if q % 2 == 0:
        ans = q // 2
    else:
        ans = q // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


def main():
    N, M = in_nn()
    a = in_nl()

    lcm = 1
    for i in range(N):
        lcm = LCM(lcm, a[i])
        if lcm > M * 10:
            print(0)
            exit()

    lcm = lcm // 2
    q = M // lcm
    if q % 2 == 0:
        ans = q // 2
    else:
        ans = q // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


def main():
    N, M = in_nn()
    a = in_nl()

    lcm = 1
    for i in range(N):
        lcm = LCM(lcm, a[i])
        if lcm > M * 2:
            print(0)
            exit()

    lcm = lcm // 2
    q = M // lcm
    if q % 2 == 0:
        ans = q // 2
    else:
        ans = q // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


def main():
    N, M = in_nn()
    a = in_nl()

    lcm = 1
    for i in range(N):
        lcm = LCM(lcm, a[i])
        if lcm >= M * 2:
            print(0)
            exit()

    lcm = lcm // 2
    q = M // lcm
    if q % 2 == 0:
        ans = q // 2
    else:
        ans = q // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()

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)
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
d=lcm(*a)*2
print((m+d//2)//d)

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

Submission status: Wrong Answer

Solution code:
import math
n,m= map(int,input().split())
al= list(map(int,input().split()))
lcmv=al[0]
for i in range(1,n):lcmv = lcmv*al[i] // math.gcd(lcmv,al[i])
print(max(0,1 + (m-lcmv//2)//lcmv))

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce

N, M, *A = map(int, open(0).read().split())

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

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

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


x = [v // 2 for v in A]
flag1 = all(M % v == 0 for v in x)
flag2 = all(even_count(v) == even_count(x[0]) for v in x)

if flag1 or flag2:
    num = lcm_list(x)
    print(-(-(M // num) // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce

N, M, *A = map(int, open(0).read().split())

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

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

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


flag1 = all(M % v == 0 for v in A)
flag2 = all(even_count(v) == even_count(A[0]) for v in A)

if flag1 or flag2:
    num = lcm_list([v // 2 for v in A])
    print(-(-(M // num) // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce

N, M, *A = map(int, open(0).read().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])
if num % 2 == 1:
    print(-(-(M // num) // 2))
else:
    c = 0
    while num % 2 == 0:
        c += 1
        num //= 2

    cnt = 0
    for i in range(20):
        cnt += -(-(M // (num * 2 ** (c + i))) // 2)
    print(cnt)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


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

lcma = lcm_list(a)
count = 0
i = 1

while(1):
    if(lcma * i <= m):
        count += 1
        i += 2
    else:
        break

if (n > 1):
    print(count)
else:
    print((m+2*lcma) // (4*lcma))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


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

lcma = lcm_list(a)
count = 0
i = 1

while(1):
    if(lcma * i <= m):
        count += 1
        i += 2
    else:
        break

if (n > 1):
    print(count)
else:
    print((m-lcma) // (2*lcma))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


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

lcma = lcm_list(a)
count = 0
i = 1

while(1):
    if(lcma * i <= m):
        count += 1
        i += 2
    else:
        break

print(count)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


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

lcma = lcm_list(a)
count = 0
i = 1

while(1):
    if(lcma * i < m):
        count += 1
        i += 2
    else:
        break

print(count)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


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

lcma = lcm_list(a)
print(( m + lcma) // (2*lcma))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

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

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


n, m  = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

lcma = lcm_list(a)
print((2 * m + lcma) // (2 *lcma))

Submission status: Wrong Answer

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)

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

A2=[i//2 for i in A]

LCM=lcm(*A2)

print((M//LCM)//2+(M//LCM)%2)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    A = tuple(map(int,input().split()))
    ans = count(A, N, M)
    print(ans)
def count(A, N, M):
    t = hMt(A[0])
    B = [A[0]//(2**t)]
    for val in A[1:]:
        if hMt(val) != t:
            ans = 0
            return ans
        B.append(val//(2**t))
    T = nlcm(B)
    MdivT = (M//(2**t))//T
    ans = countodd(MdivT)
    return ans
def countodd(M):
    if M%2 == 0:
        ans = M//2
    else:
        ans = M//2 + M%2
    return ans
def nlcm(A):
    LCM = A[0]
    for val in A[1:]:
        #print("%d %d gcm:%d LCM:%d"%(LCM,val,gcm(LCM,val),lcm(LCM,val)))
        LCM = lcm(LCM,val)
    return LCM
    
def gcm(a, b):
    abtuple = (a,b)
    abmin = min([0,1], key=lambda x:abtuple[x])
    remainder = abtuple[1-abmin]%abtuple[abmin]
    if remainder == 0:
        return abtuple[abmin]
    return gcm(abtuple[abmin], remainder)
def lcm(a,b):
    prod = a*b
    ans = prod//gcm(a,b)
    return ans
def hMt(num):
    ans = 0
    tmp = num
    while tmp%2 == 0:
        tmp = tmp//2
        ans += 1
    return ans
main()

Submission status: Wrong Answer

Solution code:
from random import randrange
def main():
    N, M = map(int,input().split())
    A = tuple(map(int,input().split()))
    AsLCM = nLCM(A,N)
    ans = count(A,N, M, AsLCM)
    print(ans)
def count(A, N, M, AsLCM):
    if AsLCM >= 2*M:
        ans = 0
        return ans
    tPpw = 2*M//AsLCM
    if tPpw%2 == 0:
        tPpw -= 1
    ans = tPpw//2 + 1
    return ans
def nLCM(A,N):
    LCM = A[0]
    for val in A[1:]:
        LCM = abLCM(LCM, val)
    return LCM
def abLCM(a,b):
    ans = a*b
    ans = ans//abGCM(a,b)
    return ans
def abGCM(a, b):
    abList = [a,b]
    minab = min([0,1],key=lambda x:[a,b][x])
    remainder = abList[1-minab]%abList[minab]
    if remainder == 0:
        return abList[minab]
    return abGCM(abList[minab], remainder)
main()

Submission status: Wrong Answer

Solution code:
from random import randrange
def main():
    N, M = map(int,input().split())
    A = tuple(map(int,input().split()))
    AsLCM = nLCM(A,N)
    ans = count(A,N, M, AsLCM)
    print(ans)
def count(A, N, M, AsLCM):
    if AsLCM > M:
        return 0
    tPpw = 2*M//AsLCM
    if tPpw%2 == 0:
        tPpw -= 1
    ans = tPpw//2 + 1
    return ans
def nLCM(A,N):
    LCM = A[0]
    for val in A[1:]:
        LCM = abLCM(LCM, val)
    return LCM
def abLCM(a,b):
    ans = a*b
    ans = ans//abGCM(a,b)
    return ans
def abGCM(a, b):
    abList = [a,b]
    minab = min([0,1],key=lambda x:[a,b][x])
    remainder = abList[1-minab]%abList[minab]
    if remainder == 0:
        return abList[minab]
    return abGCM(abList[minab], remainder)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int,input().split())
    A = tuple(map(int,input().split()))
    AsLCM = nLCM(A,N)
    P = 2*M//AsLCM
    ans = P//2 + P%2
    print(ans)
def nLCM(A,N):
    LCM = A[0]
    for val in A[1:]:
        LCM = abLCM(LCM, val)
    return LCM
def abLCM(a,b):
    ans = a*b
    ans = ans//abGCM(a,b)
    return ans
def nGCM(A,N):
    GCM = A[0]
    for val in A[1:]:
        GCM = abGCM(GCM,val) 
    return GCM
def abGCM(a, b):
    abList = [a,b]
    minab = min([0,1],key=lambda x:[a,b][x])
    remainder = abList[1-minab]%abList[minab]
    if remainder == 0:
        return abList[minab]
    return abGCM(abList[minab], remainder)
main()

Submission status: Wrong Answer

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

mul = 1
for i in A:
    mul*=i
    mul/=2
    if mul>M:
        print(0)
        exit()
print(math.ceil(M/(mul*2)))

Submission status: Wrong Answer

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

mul = 1
for i in A:
    mul*=i
    mul/=2
    if mul>M:
        print(0)
        exit()
print(math.ceil((M/mul)/2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N,M = I()
a = l()
num1 = format(a[0],'b')[::-1].find('1')
num2 = 1
for i in range(N):
  num2 = lcm(num2,a[i])
  if num1 != format(a[i],'b')[::-1].find('1'):
    print(0)
    exit()
print(math.ceil(M/num2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N,M = I()
a = l()
num1 = format(a[0],'b')[::-1].find('1')
num2 = 1
for i in range(N):
  num2 = lcm(num2,a[i])
  if num1 != format(a[i],'b')[::-1].find('1'):
    print(0)
    exit()
print(math.ceil(M//num2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N,M = I()
a = l()
num1 = format(a[0],'b')[::-1].find('1')
num2 = 1
for i in range(N):
  num2 = lcm(num2,a[i])
  if num1 != format(a[i],'b')[::-1].find('1'):
    print(0)
    exit()
num2 = num2//(2**num1)
print(math.ceil(M//num2/2))

Submission status: Wrong Answer

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)
	if(n == 1):
		return int(m//((l[0]*0.5)))
	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
	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: Wrong Answer

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
	# print(g,l,'::',m)
	return ceil(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: Wrong Answer

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)
	d = defaultdict(int)
	for i in l:
		zz = 1
		while(1 <= i*(zz+0.5) <= m):
			d[i*(zz+0.5)] += 1
			zz += 1
	ans = 0
	for i in d:
		if(d[i] == n):
			ans += 1
	return ans

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: Wrong Answer

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):
	n = len(l)
	d = defaultdict(int)
	done = defaultdict(int)
	for i in l:
		if(not done[i]):
			done[i] = 1
			zz = 1
			while(i*(zz+0.5) <= m):
				d[i*(zz+0.5)] += 1
				zz += 1
	ans = 0
	for i in d:
		if(d[i] == n):
			ans += 1
	return ans

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: Wrong Answer

Solution code:
import math

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

A = [int(_) for _ in input().split()]

for i in range(N):
    a = A[i]
    if a % 2 > 0:
        print(0)
        exit()
    A[i] = a // 2


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


c = f(A[0])
for i in range(N):
    if c != f(A[i]):
        print(0)
        exit()
    if c > 0:
        A[i] //= c

if c > 0:
    M //= c


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


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


l = 1
for a in A:
    l = lcm(l, a)
if l > M:
    print(0)
    exit()
print(math.ceil((M // l) / 2))

Submission status: Wrong Answer

Solution code:
import math

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

A = [int(_) // 2 for _ in input().split()]


def f(v):
    res = 0
    while v > 0 and v % 2 == 0:
        res += 1
        v //= 2
    return res


c = f(A[0])
for i in range(N):
    if c != f(A[i]):
        print(0)
        exit()
    if c > 0:
        A[i] //= c

if c > 0:
    M //= c


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


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


g = A[0]
l = 1
for a in A:
    l = lcm(l,a)
if l>M:
    print(0)
    exit()
print(math.ceil((M // l)/2))

Submission status: Wrong Answer

Solution code:
import math

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

A = [int(_) // 2 for _ in input().split()]


def f(v):
    res = 0
    while v > 0 and v % 2 == 0:
        res += 1
        v //= 2
    return res


c = f(A[0])
for i in range(N):
    if c != f(A[i]):
        print(0)
        exit()
    if c > 0:
        A[i] //= c

if c > 0:
    M //= c


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


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


g = A[0]
l = 1
for a in A:
    l = lcm(l,a)
print(math.ceil((M // l)/2))

Submission status: Wrong Answer

Solution code:
import functools
n,m = map(int,input().split())
L = list(map(int,input().split()))
L = [x//2 for x in L]
def ll(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//ll(a,b)
def lc(a):
    return functools.reduce(lcm,L)
d = lc(L)

if m//d%2 ==1:
    em = m//d//2+1
elif m//d%2 == 0:
    em = m//d//2
print(em)

Submission status: Wrong Answer

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

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

n,m=map(int,input().split())
A=list(map(int,input().split()))
g=1
for a in A:
    g = lcm(g,a//2)
p=0
while True:
    if g * (2 * p +1) <= m:
        p += 1
    else:
        break
print(p)

Submission status: Wrong Answer

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

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

n,m=map(int,input().split())
A=list(map(int,input().split()))
g=1
for a in A:
    g = lcm(g,a)
ans = int(m/g + 0.5)
print(ans)

Submission status: Wrong Answer

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

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

n,m=map(int,input().split())
A=list(map(int,input().split()))
g=1
for a in A:
    g = lcm(g,a)
ans = int(m/g + 1)
print(ans)

Submission status: Wrong Answer

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

import sys
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
#%%
ans = 0
L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L>2*M:
        print(0)
        sys.exit()

L2 = L
L1 = L//2
for a in A:
    if (L1//a)&1==0:
        print(0)
        sys.exit()
ans = M//L1 - M//L2
print(ans)

Submission status: Wrong Answer

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

import sys
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
#%%
ans = 0
L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L>2*M:
        print(0)
        sys.exit()

L2 = L
L1 = L//2

ans = M//L1 - M//L2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import gcd
from copy import deepcopy

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    A_ = deepcopy(A)
    cnt = [0] * n
    for i in range(n):
        while A_[i] % 2 == 0:
            A_[i] //= 2
            cnt[i] += 1
        if i != 0 and cnt[i] != cnt[i - 1]:
            print(0)
            exit()

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

    total = ((m + L - 1) // L)
    res = (total + 1) // 2
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
from math import gcd
from copy import deepcopy
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    
    A_ = deepcopy(A)
    cnt = [0] * n
    for i in range(n):
        while A_[i] % 2 == 0:
            A_[i] //= 2
            cnt[i] += 1
        if i != 0 and cnt[i] != cnt[i - 1]:
            print(0)
            exit()

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

    res = ((m + L - 1) // L) // 2
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    cnt = [0] * n
    flg = True
    while flg:
        for i in range(n):
            if A[i] % 2 != 0:
                flg = False
                break
            A[i] //= 2
            cnt[i] += 1

    if len(set(cnt)) != 1:
        print(0)
        exit()

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

    res = ((m + L - 1) // L) // 2
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

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

def f(n):
    cnt = 0
    while n:
        if n % 2 == 0:
            n //= 2
            cnt += 1
        else:
            break
    return f

l = A[0]//2
cnt = f(l)

for k in range(1, N):
    a = A[k]//2
    c = f(a)
    if cnt != c:
        print(0)
        exit()
    l = lcm(l, a)

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

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

def main():
    N, M = LI()
    A = LI()
    g = 1
    for i in range(N):
        A[i] //= 2
        g = lcm(g, A[i])

    first_even = A[0] % 2
    for a in A:
        if a % 2 != first_even:
            print(0)
            return

    shou = M // g
    if shou % 2 == 1:
        shou -= 1
        ans = shou // 2
        ans += 1
    else:
        ans = shou // 2
    print(ans)


main()