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:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = 998244353
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    A = Scanner.map_int()
    L = 1
    for i in range(N):
        L = Math.lcm(L, A[i] // 2)
    print(Math.roundUp(M // L, 2))
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

flag = 0
for i in range(n):
    if a[i] % 2 != 1:
        flag = 1
        break
    a[i] //= 2

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

t = f(a[0])
for i in range(1, n):
    if f(a[i]) != t:
        flag = 1
        break
    a[i] >>= t

m >>= t

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

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        flag = 1
        break

m //= l
ans = (m + 1) // 2
if flag == 1:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

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

flag = 0
t = f(a[0])
for i in range(1, n):
    if f(a[i]) != t:
        flag = 1
        break
    a[i] >>= t

m >>= t

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

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        flag = 1
        break

m //= l
ans = (m + 1) // 2
if flag == 1:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
num = 1
for x in a:
    num = num * (x//2) // fractions.gcd(num, x//2)
print(m//num-(m//num)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    from fractions import gcd

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

    t = A[0]
    n = 1
    while t % 2 == 0:
        n *= 2
        t //= 2

    for a in A:
        if a % n != 0 or (a // n) % 2 == 0:
            print(0)
            return

    lcm = 1
    for a in A:
        lcm = lcm * a // gcd(lcm, a)
        if lcm // 2 > M:
            print(0)
            return

    print((M - t // 2) // t + 1)


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_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = list(map(lambda x: x // 2, a))

lcm = lcm_list(aa)

for b in a:
    if (lcm - (b // 2)) % b == 0:
        k = (lcm - (b // 2)) // b
        if k * lcm > M:
            print(0)
            exit(0)
    else:
        print(0)
        exit(0)

answer = ((M - lcm) // (lcm * 2)) + 1
print(answer)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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

N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = list(map(lambda x: x // 2, a))

lcm = lcm_list(aa)

# m = max(a)
# print(m)

for b in a:
    if (lcm - (b // 2)) % b == 0:
        k = (lcm - (b // 2)) // b
        if k * lcm > M:
            print(0)
            exit(0)
    else:
        print(0)
        exit(0)

answer = M // lcm
if answer % 2 == 0:
    answer = answer // 2
else:
    answer = (answer // 2) + 1
print(answer)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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

N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = list(map(lambda x: x // 2, a))

for aaa in aa:
    if aaa % 2 == 0:
        print(0)
        exit(0)

lcm = lcm_list(aa)
answer = M // lcm
if answer % 2 == 0:
    answer = answer // 2
else:
    answer = (answer // 2) + 1
print(answer)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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

N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = list(map(lambda x: x // 2, a))

lcm = lcm_list(aa)
answer = M // lcm
if answer % 2 == 0:
    answer = answer // 2
else:
    answer = (answer // 2) + 1
print(answer)

Submission status: Wrong Answer

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    A = tuple(map(int, f_i.readline().split()))
    
    def fact2(num):
        cnt = 0
        while num % 2 == 0:
            num //= 2
            cnt += 1
    
    f = fact2(A[0])
    for a in A[1:]:
        if f != fact2(a):
            return 0
    
    from fractions import gcd
    def lcm(a, b):
        return a * b // gcd(a, b)
    
    import functools
    def mul_lcm(nums):
        return functools.reduce(lcm, nums)
    
    half_A = (a // 2 for a in A)
    l = mul_lcm(half_A)
    
    return (M // l + 1) // 2

print(solve())

Submission status: Wrong Answer

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    A = tuple(map(int, f_i.readline().split()))
    
    def fact2(num):
        cnt = 0
        while num % 2 == 0:
            num //= 2
            cnt += 1
    
    f = fact2(A[0])
    for a in A[1:]:
        if f != fact2(a):
            return 0
    
    from fractions import gcd
    def lcm(a, b):
        return a * b // gcd(a, b)
    
    import functools
    def mul_lcm(nums):
        return functools.reduce(lcm, nums)
    
    half_A = (a // 2 for a in A)
    g = mul_lcm(half_A)
    
    cnt = M // g
    q, r = divmod(cnt, 2)
    
    return q + r

print(solve())

Submission status: Wrong Answer

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    A = tuple(map(int, f_i.readline().split()))
    
    def fact2(num):
        cnt = 0
        while num % 2 == 0:
            num //= 2
            cnt += 1
    
    f = fact2(A[0])
    for a in A[1:]:
        if f != fact2(a):
            return 0
    
    from fractions import gcd
    def lcm(a, b):
        return a * b // int(gcd(a, b))
    
    import functools
    def mul_lcm(nums):
        return functools.reduce(lcm, nums)
    
    half_A = (a // 2 for a in A)
    g = mul_lcm(half_A)
    
    cnt = M // g
    q, r = divmod(cnt, 2)
    
    return q + r

print(solve())

Submission status: Wrong Answer

Solution code:
from sys import exit
from fractions import gcd

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


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

A = list(set(A))

t = 1
for a in A:
    t = lcm(t, a)
    if t // 2 > M:
        print(0)
        exit()

print((M - t // 2) // t + 1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
def f(n):
    res = 0
    while(n%2 == 0):
        res += 1
        n //= 2
    return res

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

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

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

F = set()
for a in A:
    F.add(f(a))
if(len(F) != 1):
    print(0)
    exit()

l = reduce(lcm, A, 1)
for a in A:
    if((l // a) % 2 == 0):
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
def f(n):
    res = 0
    while(n%2 == 0):
        res += 1
        n //= 2
    return res

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

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

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

F = set()
for a in A:
    F.add(f(a))
if(len(F) != 1):
    print(0)
    exit()

l = reduce(lcm, A, 1)
for a in A:
    if((l // a) % 2 == 0):
        print(0)
        exit()

ans = 0 if (l == 0) else (- (- (m // 2) // l))
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
def f(n):
    res = 0
    while(n%2 == 0):
        res += 1
        n //= 2
    return res

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

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

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

F = set()
for a in A:
    F.add(f(a))
if(len(F) != 1):
    print(0)
    exit()

l = reduce(lcm, A, 1)
if(l % 2 == 0):
    print(0)
    exit()

ans = 0 if (l == 0) else (- (- (m // 2) // l))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
 
input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []
 
input2 = input().split()


#1個ずつリストに放り込む
for i in range(N):
    a_n.append(int(input2[i]))

#後の計算量減らすために重複した要素を削除
a_n = list(set(a_n))
 
#a_nの最小公倍数を計算 
ans = a_n[0]
for i in range(1, len(a_n)):
    ans = ans * a_n[i] // fractions.gcd(ans, a_n[i])

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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

D = [] * len(A)

for i in A:
  con = 0
  while i % 2 == 0:
    i = i // 2
    con += 1
  D.append(con)

if len(set(D)) != 1:
  print("No")

else:
  A = [i // 2 for i in A]
      
  def lcm(a,b):
      return (a * b) // fractions.gcd(a, b)
  
  def gcd_list(numbers):
      return reduce(fractions.gcd, numbers)
  
  def lcm_list(numbers):
      return reduce(lcm, numbers, 1)
      
  LCM = lcm_list(A)
  
  up = M // LCM
  
  ans = len([i * LCM for i in range(1,up + 1,2)])
  
  print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
X=[]
ans=0

for i in range(M):
  x = int(a[0]*(i+0.5))
  if x <= M:
    X.append(x)
  else:
    break

for i in X:
  count=0
  for j in a[1:]:
    x = i/j
    if (x*2).is_integer():
      count+=1
    else:
      break
  if count==(N-1):
    ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

def ex_euclid(x,y):
    c0,c1 = x,y
    a0,a1 = 1,0
    b0,b1 = 0,1
    while c1:
        a0,a1 = a1,a0-c0//c1*a1
        b0,b1 = b1,b0-c0//c1*b1
        c0,c1 = c1,c0%c1
    return c0,a0,b0

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

LCM = reduce(lcm,A)

SCMs = [1]
flag = True

for i in range(N-1):
    c,a,b = ex_euclid(A[i],-A[i+1])
    if (A[i+1]-A[i])//2%c == 0:
        SCMs.append(A[i]*((A[i+1]-A[i])//2//c)*a+A[i]//2)
    else:
        flag = False
        break

print((M-reduce(lcm,SCMs)%LCM)//LCM+1 if flag else 0)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import fractions

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

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

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

lcm = 1

for a in a_list:
  lcm = lcm_base(lcm, a)

for a in a_list:
  if (lcm // a) % 2 == 0:
    lcm = 0
    break
if lcm == 0:
  print(0)
else:
  ans = -(-M//(lcm//2))/2
  if ans == 0.5:
    print(1)
  else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import fractions

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

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

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

lcm = 1

for a in a_list:
  lcm = lcm_base(lcm, a)

for a in a_list:
  if (lcm // a) % 2 == 0:
    lcm = 0
    break
if lcm == 0:
  print(0)
else:
  print(int(-(-M//(lcm//2))/2))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import fractions

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

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

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

lcm = 1

for a in a_list:
  lcm = lcm_base(lcm, a)

for a in a_list:
  if (lcm // a) % 2 == 0:
    lcm = 0
    break
if lcm == 0:
  print(0)
else:
  print(-(-M//lcm))

Submission status: Wrong Answer

Solution code:
import sys

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

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm/i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Submission status: Wrong Answer

Solution code:
import sys

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

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd (lcm,i)
for i in a:
    if (lcm/a)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
from fractions import gcd

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	A = getlist()
	B = [int(A[i] // 2) for i in range(N)]
	LCM = B[0]
	for i in range(N - 1):
		GCD = gcd(LCM, B[i + 1])
		LCM = int(LCM * B[i + 1] / GCD)
		if LCM >= 10 ** 10:
			break

	if LCM > M:
		print(0)
	else:
		ans = (M - LCM) // (2 * LCM) + 1
		for i in range(N):
			if B[i] % 2 == 0:
				ans = 0
		print(ans)



if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
from fractions import gcd

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	A = getlist()
	B = [int(A[i] // 2) for i in range(N)]
	LCM = B[0]
	for i in range(N - 1):
		GCD = gcd(LCM, B[i + 1])
		LCM = int(LCM * B[i + 1] / GCD)
		if LCM >= 10 ** 10:
			break

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


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

l = set(map(int,input().split()))
l = list(l)
l = [i//2 for i in l]
lc = 1
gc =1
for i in l:
    gc = gcd(gc,i)
    lc = lc*i//gcd(lc,i)
if (lc//gc)%2==0:
    print(0)
else:
    print((m//lc +1)//2)

Submission status: Wrong Answer

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

l = set(map(int,input().split()))
l = list(l)
l = [i//2 for i in l]
lc = 1
gc =1
for i in l:
    gc = gcd(gc,i)
    lc = lc*i//gcd(lc,i)
if (lc//gc)%2==0:
    print(0)
else:
    print(math.ceil(m/(lc))//2)

Submission status: Wrong Answer

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

l = set(map(int,input().split()))
l = list(l)
l = [i//2 for i in l]
lc = 1
gc =1
for i in l:
    gc = gcd(gc,i)
    lc = lc*i//gcd(lc,i)
if (lc//gc)%2==0:
    print(0)
else:
    print(math.ceil(m/(2*lc)))

Submission status: Wrong Answer

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

l = set(map(int,input().split()))

l = list(l)
lc = 1
gc =1
for i in l:
    gc = gcd(gc,i)
    lc = lc*i//gcd(lc,i)
if (lc//gc)&1==0:
    print(0)
else:
    print(math.ceil(m/lc))

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X = MI()
    A=sorted(LI())
    lcm = 1
    for a in A:
        a//=2
        lcm = a*lcm//gcd(a,lcm)
        if (lcm//a)%2==0:
            lcm *= 2
        if X<lcm:
            print(0)
            return
    print(ceil(X//lcm,2))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X = MI()
    A=sorted(LI())
    lcm = 1
    for a in A:
        a//=2
        lcm = a*lcm//gcd(a,lcm)
        if (lcm//a)%2==0:
            lcm *= 2
        if X<lcm:
            print(0)
            return
    print(ceil(X//lcm/2))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X = MI()
    A=sorted(LI())
    lcm = 1
    for a in A:
        a//=2
        lcm = a*lcm//gcd(a,lcm)
        if (lcm//a)%2==0:
            lcm *= 2
    print(ceil(X//lcm/2))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

N = input().split()
N = [int(i) for i in N]
A = input().split()
a = [int(i)//2 for i in A]

mul = 1
mul = gcd(a)

if(mul%2==0):
    print(0)
    #print('even')
else:
    n = N[1]//mul
    n = (n+1)//2
    print(n)

Submission status: Wrong Answer

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

N = input().split()
N = [int(i) for i in N]
A = input().split()
a = [int(i)//2 for i in A]

mul = 1
mul = gcd(a)

if(mul%2==0):
    print(0)
    #print('even')
else:
    n = N[1]//mul
    n = (n-1)//2 + 1
    print(n)

Submission status: Wrong Answer

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

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

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

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

temp=A[-1]//2

for item in A:
    if temp%item!=item//2:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

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

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

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

B=[A[-1]//2]



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

Submission status: Wrong Answer

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

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

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

for item in A:
    if item==2 or (item//2)%2==0:
        print(0)
        exit()

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

B=[A[-1]//2]

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

Submission status: Wrong Answer

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

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

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

for item in A:
    if item%4==0:
        print(0)
        exit()

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

B=[A[-1]//2]

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

Submission status: Wrong Answer

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 0
l = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  b=i//2
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==0:
    cnt=cnt1
    l+=1
  else:
    if cnt!=cnt1:
      print(0)
      exit()
if l==N and cnt!=0:
  print(0)
  exit()
print((M//a+2-1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 0
l = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  b=i//2
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==0:
    cnt=cnt1
    l+=1
  else:
    if cnt!=cnt1:
      print(0)
      exit()
if l==N:
  print(0)
  exit()
print((M//a+2-1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  i=i//2
  b = a//i
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==0:
    cnt=cnt1
  else:
    if cnt!=cnt1:
      print(0)
      exit()
print((M//a+2-1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  i=i//2
  b = a//i
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==0:
    cnt=cnt1
  else:
    if cnt!=cnt1:
      print(0)
      exit()
print(a)
print((M//a+2-1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
for i in A:
  i = i//2
  a = lcm(a,i)
print((M//a+2-1)//2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=set([i/2 for i in A])
def gcd(a,b):
    if (a>b):a,b=b,a
    while a%b:
        a,b=b,a%b
    return b

prodA=1
for i in A:
    prodA*=i
print(int((M/prodA+1)//2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[i/2 for i in A]
def gcd(a,b):
    if (a>b):a,b=b,a
    while a%b:
        a,b=b,a%b
    return b

def lcmList(A):
    tmp=A[0]
    for i in range(len(A)-1):
        tmp=tmp*A[i+1]/gcd(tmp,A[i+1])
    return tmp

prodA=lcmList(A)
print(int((M/prodA+1)//2))

Submission status: Wrong Answer

Solution code:
import sys, fractions
input = sys.stdin.readline
N,M = map(int,input().split())
aa = list(map(int, input().split()))

lcm = 1
i = 1
for a in aa:
    lcm = a*lcm//fractions.gcd(a,lcm)

ans = 0
ans += (M // lcm)
if (M % lcm) >= (lcm//2):
	ans += 1

print(ans)

Submission status: Wrong Answer

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

p = 0
buf = []
buf2 = []
for i, j in enumerate(a):
    buf.append([])
    while True:
        x = j * (p + 0.5)
        p += 1

        if x > m:
            p = 0
            if i > 0:
                buf2 =  list(set(buf[i]) & set(buf[i - 1]))
            else:
                buf2 = buf[0]
            break

        if x not in buf[i]:
            buf[i].append(x)

print(len(buf2))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    from fractions import gcd
    l = 1
    for i in A:
        l = (l*i)//gcd(l,i)
        if l//2 >= 10**9:
            l = float('inf')
            break
    l //= 2
    ans = (M+l)//(2*l)
    
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    from fractions import gcd
    l = 1
    for i in A:
        l = (l*i)//gcd(l,i)
        if l >= 10**9:
            l = float('inf')
            break
    l //= 2
    ans = (M+l)//(2*l)
    
    print(ans)