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
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

##### 進数の変換 #####
# bin_str = bin(i)
# oct_str = oct(i)
# hex_str = hex(i)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,M = inputMap()
	A = inputList()

	lcm_A = 1
	for i in A:
		lcm_A = lcm(lcm_A,i)

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

	wareru2 = shino(A[0])
	for i in A:
		tmp = shino(i)
		if tmp == wareru2:
			pass
		else:
			print(0)
			sys.exit()

	ans = M // pow(2, wareru2)
	#print(ans)
	#print(lcm_A)
	ans = -(-(ans*2) // (lcm_A))

	print(ans)

def shino(x):
	ret = 0
	while True:
		if x % 2 == 0:
			ret += 1
			x = x // 2
		else:
			return ret


# a と b の最大公約数を求めるユークリッドの互除法
def gcd(a, b):
	if a > b:
		a, b = b, a

	while a > 0:
		a, b = b % a, a
	return b

# a と b の最小公倍数を求める。以下の公式を使用
# a x b == (a と b の最大公約数) x (a と b の最小公売数)
def lcm(a, b):
	g = gcd(a, b)
	return a // g * b

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# N 個のボールを K グループに分ける場合のパターン数
def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

def sks(n):
	global alist
	if n == 1:
		return alist[0]
	else:
		tmp=sks(n-1)
		return tmp*alist[n-1]/fractions.gcd(tmp,alist[n-1])

sk = sks(n)

gomi=sk/2

for a in alist:
	if (gomi-a/2)%a != 0:
		print(0)
		sys.exit()

print(int((m+gomi)//sk))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd
import math

def main():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    tmp = 1
    for i in range(N):
      tmp = tmp * a[i] // gcd(tmp,a[i])
    tmp2 = tmp//2
    if tmp == max(a):
      tmp2 += tmp
    print(math.ceil((M-tmp2+1)/tmp))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd

def main():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    tmp = 1
    for i in range(N):
      tmp = tmp * a[i] // gcd(tmp,a[i])
    tmp2 = tmp//2
    if tmp2 == max(a):
      tmp2 += tmp
    print((M+tmp2)//tmp)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd

def main():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    tmp = 1
    for i in range(N):
      tmp = tmp * a[i] // gcd(tmp,a[i])
    print((M+tmp//2)//tmp)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

c = 1
for e in a:
    c = lcm(c, e // 2)

ans = 0
if c <= M:
    ans += 1
    M -= c
ans += M // (c * 2)
print(0)

Submission status: Wrong Answer

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

c = 1
for e in a:
    c = lcm(c, e // 2)

ans = 0
if c <= M:
    ans += 1
    M -= c
ans += M // (c * 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

c = 1
for e in a:
    c = lcm(c, e)

ans = 0
M *= 2
if c <= M:
    ans += 1
    M -= c
ans += M // (c * 2)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [a[i] // 2 for i in range(n)]
    a = list(set(a))
    n = len(a)
    lcm = 1
    for i in range(n):
        lcm = lcm * a[i] // gcd(lcm, a[i])
    ans = m // lcm
    print(ans - ans // 2)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [a[i] // 2 for i in range(n)]
    a = list(set(a))
    n = len(a)
    lcm = 1
    for i in range(n):
        lcm = lcm * a[i] // gcd(lcm, a[i])
    print((m - lcm) // (2 * lcm) + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [a[i] // 2 for i in range(n)]
    a = list(set(a))
    n = len(a)
    lcm = a[0]
    for i in range(1, n):
        lcm = lcm * a[i] // gcd(lcm, a[i])
    print(((m - lcm) // (2 * lcm)) + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [a[i] // 2 for i in range(n)]
    a = list(set(a))
    n = len(a)
    lcm = a[0]
    for i in range(1, n):
        lcm = lcm * a[i] // gcd(lcm, a[i])
    print((m + lcm) // (2 * lcm))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    div2_count = []

    for a in A:
        l = l*a // gcd(l, a)
        c = count_div2(a)
        div2_count.append(max(count_div2(a), 1))
    l *= min(div2_count)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


def count_div2(x):
    ans = 0
    while x % 2 == 0:
        x = x//2
        ans += 1
    return ans


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    max_div2 = 1
    for a in A:
        l = l*a // gcd(l, a)
        c = count_div2(a)
        if max_div2 <= c:
            max_div2 = c
    l *= max_div2
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


def count_div2(x):
    ans = 0
    while x % 2 == 0:
        x = x//2
        ans += 1
    return ans


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 2
    for a in A:
        l = l*a // gcd(l, a)

    # l の奇数倍がM*max(A)以下にいくつあるか

    if l < max(A):
        ref = 1
    else:
        ref = 0
    print(((M*2)//l + 1)//2-ref)
    # print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)

    # l の奇数倍がM*max(A)以下にいくつあるか

    if l < max(A):
        ref = 1
    else:
        ref = 0
    print((M//l + 1)//2-ref)
    # print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

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

    l = 1
    for a in A:
        l = l*a // gcd(l, a)

    # l の奇数倍がM*max(A)以下にいくつあるか
    print((M//l + 1)//2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
a=list(map(int,input().split()))
c=[]
for i in range(1,M+1):
    counter=0
    for j in a:
        l1=(i-j//2)/j
        l2=(i-j//2)//j
        if l2!=0 and l1==l2:
            counter+=1
    if counter==N:
        c.append(i)
print(len(c))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d


def main():
    n, m = map(int, input().split(" "))
    a = [int(s) for s in input().split(" ")]
    kou = 1
    # 最小公倍数を求める方法が間違ってる
    for i in a:
        j = i // 2
        kou = lcm(kou, j)
    count = m // kou
    if count % 2 == 0:
        count //= 2
    else:
        count = count // 2 + 1
    print(count)


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


def gcd(n, m):
    if n == m:
        return n
    i = max(n, m)
    j = min(n, m)
    p = i % j
    while p != 0:
        i = j
        j = p
        p = i % j
    return j


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


N,M = map(int,input().split())
b = list(map(int,input().split()))
LCM = b[0]

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM//2 > M:
    print(0)
    exit()

print(int((1+(M//LCM*2)//2)))

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


N,M = map(int,input().split())
b = list(map(int,input().split()))
LCM = b[0]

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

print(LCM)

if LCM//2 > M:
    print(0)
    exit()

print(int((1+(M//LCM*2)//2)))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# TODO: try


def main():
    n, m = map(int, input().split(" "))
    # array = {int(s) for s in input().split(" ")}
    # count = 0
    # for i in range(m, 0, -1):
    #     has = 0
    #     for j in range(1, n + 1):
    #         for s in array:
    #             if s % (j + 0.5) == 0:
    #                 has += 1
    #     if has == 3:
    #         count += 1
    # print(count)
    a = [int(s) for s in input().split(" ")]
    appear = set()
    kou = 1
    # 最小公倍数を求める方法が間違ってる
    for i in a:
        j = i // 2
        kou = lcm(kou, j)
    if m > kou:
        print(((m - kou) // (2 * kou)) + 1)
    else:
        print("0")


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


def gcd(n, m):
    if n == m:
        return n
    i = max(n, m)
    j = min(n, m)
    p = i % j
    while p != 0:
        i = j
        j = p
        p = i % j
    return j


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


N,M = map(int,input().split())
b = list(map(int,input().split()))
LCM = b[0]

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM//2 > M:
    print(0)
    exit()

print(int((1+(M-LCM//2)//(LCM))))

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


N,M = map(int,input().split())
b = list(map(int,input().split()))
LCM = b[0]

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

print(LCM)

if LCM > M:
    print(0)
    exit()

print(int((1+(M-LCM//2)//(LCM))))

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


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

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM > M:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


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

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM > M:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)


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

check=0
tmp = b[0]
while tmp !=0:
    if tmp%2 ==0:
        tmp = tmp//2
        check+=1
    else:
        break

check = pow(2,check)
for i in range(0,N,1):
    if b[i]%check != 0:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM > M:
    print(0)
    exit()

print(1+(M-LCM)//(2*LCM))

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

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

check = b[0]%2
for i in range(0,N,1):
    if b[i]%2!=check:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM > M:
    print(0)
    exit()

print((M-LCM)//(2*LCM))

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

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

check = b[0]%2
for i in range(0,N,1):
    if b[i]%2!=check:
        print(0)
        exit()

for i in range(0,N,1):
    LCM = lcm(LCM,b[i])

if LCM > M:
    print(0)
    exit()

print(1 + (M-LCM)//(2*LCM))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# TODO: try


def main():
    n, m = map(int, input().split(" "))
    # array = {int(s) for s in input().split(" ")}
    # count = 0
    # for i in range(m, 0, -1):
    #     has = 0
    #     for j in range(1, n + 1):
    #         for s in array:
    #             if s % (j + 0.5) == 0:
    #                 has += 1
    #     if has == 3:
    #         count += 1
    # print(count)
    a = [int(s) for s in input().split(" ")]
    appear = set()
    kou = 1
    for i in a:
        j = i // 2
        if j not in appear:
            kou *= j
            appear.add(j)
    if m > kou:
        print(((m - kou) // (2 * kou)) + 1)
    else:
        print("0")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# TODO: try


def main():
    n, m = map(int, input().split(" "))
    # array = {int(s) for s in input().split(" ")}
    # count = 0
    # for i in range(m, 0, -1):
    #     has = 0
    #     for j in range(1, n + 1):
    #         for s in array:
    #             if s % (j + 0.5) == 0:
    #                 has += 1
    #     if has == 3:
    #         count += 1
    # print(count)
    a = [int(s) for s in input().split(" ")]
    appear = set()
    kou = 1
    for i in a:
        j = i // 2
        while j % 2 == 0:
            j //= 2
        if j not in appear:
            kou *= j
            appear.add(j)
    if m > kou:
        print(((m - kou) // (2 * kou)) + 1)
    else:
        print("0")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# TODO: try


def main():
    n, m = map(int, input().split(" "))
    # array = {int(s) for s in input().split(" ")}
    # count = 0
    # for i in range(m, 0, -1):
    #     has = 0
    #     for j in range(1, n + 1):
    #         for s in array:
    #             if s % (j + 0.5) == 0:
    #                 has += 1
    #     if has == 3:
    #         count += 1
    # print(count)
    a = [int(s) for s in input().split(" ")]
    appear = set()
    kou = 1
    for i in a:
        j = i // 2
        if j not in appear:
            kou *= j
            appear.add(j)
    count = 0
    for i in range(kou, m, 2 * kou):
        count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

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

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

lcm_a = lcm(*a)
print(m // (lcm_a//2) - m // lcm_a)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

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

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

bef = 1
LCM = 1
ans = []
for i,a in enumerate(A):
    LCM = lcm(LCM,a)
    b = a //2
    if bef != 1 and bef%2 == 1 and b%2 == 0:
        print(0)
        exit()
    else:
        bef = lcm(bef,b)
        ans.append(bef)

print((M-bef)//LCM+1)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

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

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

bef = 1
LCM = 1
ans = []
for i,a in enumerate(A):
    LCM = lcm(LCM,a)
    b = a //2
    if i > 0 and bef%2 == 1 and b%2 == 0:
        print(0)
        exit()
    else:
        bef = lcm(bef,b)
        ans.append(bef)

print((M-bef)//LCM+1)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

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

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

bef = 1
LCM = 1
ans = []
for i,a in enumerate(A):
    LCM = lcm(LCM,a)
    b = a //2
    if i > 0:
        if bef%2 == 1 and b%2 == 0:
            print(0)
            exit()
    else:
        bef = lcm(bef,b)
        ans.append(bef)

print((M-bef)//LCM+1)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

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

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

bef = 1
LCM = 1
ans = []
for a in A:
    LCM = lcm(LCM,a)
    b = a //2
    if bef%2 == 1 and b%2 == 0:
        print(0)
        exit()
    else:
        bef = lcm(bef,b)
        ans.append(bef)

print((M-bef)//LCM+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

bef = 1
LCM = 1
ans = []
for a in A:
    LCM = lcm(LCM,a)
    b = a //2
    bef = lcm(bef,b)
    ans.append(bef)

# print(ans)
# print(M-ans[-1],LCM)
print((M-ans[-1])//LCM+1)