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:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=X<=Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# 数列Aの最小公倍数を2lcmと定義すると、答えの候補はlcmの倍数であるところまで絞り込めた。
# これで答えの候補を最小公倍数の半分、lcmの倍数であるところまで絞り込めた。

# ところでP_kは必ず奇数でなければ行けないのだから,Xとa_kは同じ回数2で割り切れなければ行けない。
# これを満たすXは,lcmがP_kと同じ回数2で割り切れる かつ lcmの奇数倍の数である。

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a // g * b


N, M = read_ints()
A = read_ints()
X = 1
for a in A:
    X = lcm(X, a)
X = X // 2

# すべてのa//2 はX(lcmと同じ回数2で割り切れないければ行けない)
lcm = X
n_div = 0
while lcm & 1 == 0:
    lcm //= 2
    n_div += 1

for a in A:
    if n_div != 0 and (a // 2) % (pow(n_div, 2)):
        print(0)  # 割り切れなかった時点でそのような半公倍数は存在しない
        exit()


print((M // X + 1) // 2)  # 奇数倍のlcmの個数 つまりすべて-偶数の分

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=X<=Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# 数列Aの最小公倍数を2lcmと定義すると、答えの候補はlcmの倍数であるところまで絞り込めた。
# これで答えの候補を最小公倍数の半分、lcmの倍数であるところまで絞り込めた。

# ところでP_kは必ず奇数でなければ行けないのだから,Xとa_kは同じ回数2で割り切れなければ行けない。
# これを満たすXは,lcmがP_kと同じ回数2で割り切れる かつ lcmの奇数倍の数である。

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a // g * b


N, M = read_ints()
A = read_ints()
X = 1
for a in A:
    X = lcm(X, a)
X = X // 2

# すべてのa//2 はX(lcmと同じ回数2で割り切れないければ行けない)
lcm = X
n_div = 0
while lcm & 1 == 0:
    lcm //= 2
    n_div += 1

for a in A:
    if n_div != 0 and (a // 2) % (pow(n_div, 2, 10 ** 10)):
        print(0)  # 割り切れなかった時点でそのような半公倍数は存在しない
        exit()


print((M // X + 1) // 2)  # 奇数倍のlcmの個数 つまりすべて-偶数の分

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=2X<=2Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# これは最小公倍数lcmを求めてから計算できる。(偶数倍のlcmはP_kが偶数になってしまうので省く必要はある)

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()
A = read_ints()
X = 1
for a in A:
    X = lcm(X, a)
X = X // 2

ans = 0

for now in ra(X, 10 ** 9, 2 * X):
    if now > M:
        break
    ans += 1
print(ans)
# print((M // X + 1) // 2)  # 奇数倍のlcmの個数 つまりすべて-偶数の分
# 間隔が公倍数の半分になるのでまさに半公倍数

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=2X<=2Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# これは最小公倍数lcmを求めてから計算できる。(偶数倍のlcmはP_kが偶数になってしまうので省く必要はある)

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()
A = read_ints()
X = 1
for a in A:
    X = lcm(X, a // 2)

# X = twoX // 2
print((M // X + 1) // 2)  # 奇数倍のlcmの個数 つまりすべて-偶数の分
# 間隔が公倍数の半分になるのでまさに半公倍数

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=2X<=2Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# これは最小公倍数lcmを求めてから計算できる。(偶数倍のlcmはP_kが偶数になってしまうので省く必要はある)

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()
A = read_ints()
twoX = 1
for a in A:
    twoX = lcm(twoX, a)

X = twoX // 2
print((M // X + 1) // 2)  # 奇数倍のlcmの個数 つまりすべて-偶数の分
# 間隔が公倍数の半分になるのでまさに半公倍数

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=2X<=2Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# これは最小公倍数lcmを求めてから計算できる。(偶数倍のlcmはP_kが偶数になってしまうので省く必要はある)

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()
A = read_ints()
twoX = 1
for a in A:
    twoX = lcm(twoX, a)

X = twoX // 2
print((M // X) - (M // (twoX)))  # 奇数倍のlcmの個数 つまりすべて-偶数の分
# 間隔が公倍数の半分になるのでまさに半公倍数

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
# 半公倍数Xとは、X=a_k (p_k + 0.5) for any k を満たす数字である(p_kは負はない整数)
# 2を掛ければ、2X=a_k P_k where P_k=2p_k+1 となる。2Xは数列Aの公倍数と解釈できる。
# よってこの問題は、a_k (k=1...N)の公倍数2X は 0<=2X<=2Mを満たす範囲にいくつ存在するか？という風に読み替えられる。
# これは最小公倍数lcmを求めてから計算できる。(偶数倍のlcmはP_kが偶数になってしまうので省く必要はある)

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from fractions import gcd


def lcm(a, b):
    # 最小公倍数 #単位元は1
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()
A = read_ints()
twoX = 1
for a in A:
    twoX = lcm(twoX, a)
print((2 * M // twoX) - (2 * M // (2 * twoX)))  # 奇数倍のlcmの個数
# 間隔が公倍数の半分になるのでまさに半公倍数

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
def lcm(a, b):
  return a * b // gcd(a, b)
half_a = [i//2 for i in a]
q = half_a[0]
for i in range(n):
  q = lcm(q,half_a[i])
ans = (m//q) - (m//(2*q))
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
half_a = [i//2 for i in a]
from fractions import gcd
def lcm(x,y):
  return (x*y) // gcd(x,y)
q = half_a[0]
for i in range(n):
  q = lcm(q,half_a[i])
ans = (m//q) - (m//(2*q))
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
half_a = [i//2 for i in a]
from fractions import gcd
def lcm(x,y):
  return (x*y) // gcd(x,y)
q = 1
for i in range(n):
  q = lcm(q,half_a[i])
ans = m//q - m//(2*q)

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        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()))
l = a[0] // 2
for i in range(n):
    a[i] //= 2
    l = lcm(l, a[i])
c = 0
for i in a:
    c += i % 2
print(((m // l) + 1) // 2 if c == n or c == 0 else 0)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        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()))
l = a[0] // 2
for i in range(n):
    a[i] //= 2
    l = lcm(l, a[i])
print(((m // l) + 1) // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

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

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M / k
if b % 2 == 0:
    print(int(b/2))
else:
    print(int((b + 1) / 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

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

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M % 2
if b == 1:
    print(int(((M / k)+1)/2))
else:
    print(int((M / k) / 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

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

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M % 2
if b == 1:
    print(((M / k)+1)/2)
else:
    print((M / k) / 2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

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

n, m = map(int, input().split())
a_array = np.array(list(map(int, input().split())))
b_array = a_array//2
if 0 in b_array%2:
    ans = 0
    print(ans)
else:
    k = b_array[0]
    for i in range(n):
        k = lcm(k, b_array[i])
    ans = (m//k)//2 + ((m//k)%2 == 1)
    print(ans)

Submission status: Wrong Answer

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

X = set([a / 2 for a in A])
b = 1
for x in X:
    b *= x

k = M % b
if k != 0:
    M -= (M % b)
k = M / b
if k % 2 == 0:
    print(int(k // 2))
else:
    print(math.ceil(k / 2))

Submission status: Wrong Answer

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

X = set([a / 2 for a in A])
b = 1
for x in X:
    b *= x

k = M % b
if k != 0:
    M -= (M % b)
k = M / b
if k % 2 == 0:
    print(k // 2)
else:
    print(math.ceil(k / 2))

Submission status: Wrong Answer

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

X = set([a / 2 for a in A])
b = 1
for x in X:
    b *= x

if M % b != 0:
    M -= M % b
if M == 0:
    print(M)
else:
    print((((M/b)-1)/2)+1)

Submission status: Wrong Answer

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

X = set([a / 2 for a in A])
b = 1
for x in X:
    b *= x
print(math.ceil(math.floor(M / b) / 2))

Submission status: Wrong Answer

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

X = set([a / 2 for a in A])
b = 1
for x in X:
    b *= x
c = 0
m = b
while m <= M:
    if m % 2 == 1:
        c += 1
    m += b
print(c)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
for i in range(n):
    a[i] //= 2
lcm_memo = 1
for i in range(n):
    lcm_memo *= a[i] // gcd(lcm_memo, a[i])
    if lcm_memo > m:
        print(0)
        exit()
for i in range(n):
    if (n // a[i]) % 2 == 0:
        print(0)
        exit()
print(1 + (m - lcm_memo) // (lcm_memo * 2))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
for i in range(n):
    a[i] //= 2
lcm_memo = 1
for i in range(n):
    lcm_memo *= a[i] // gcd(lcm_memo, a[i])
for i in range(n):
    if (n // a[i]) % 2 == 0:
        print(0)
        exit()
if lcm_memo > m:
    print(0)
    exit()
print(1 + (m - lcm_memo) // (lcm_memo * 2))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
memo = 0
cnt = 0
while a[0] % 2 == 0:
    a[0] //= 2
    memo += 1
for i in range(1, n):
    if a[i] % 2 == 0:
        a[i] //= 2
        cnt += 1
    else:
        if memo != cnt:
            print(0)
            exit()
        cnt = 0
lcm_memo = 1
for i in range(n):
    lcm_memo *= a[i] // gcd(lcm_memo, a[i])
if lcm_memo > m:
    print(0)
    exit()
print(1 + (m - lcm_memo) // (lcm_memo * 2))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from math import floor

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
memo = 0
cnt = 0
while a[0] % 2 == 0:
    a[0] //= 2
    memo += 1
for i in range(1, n):
    if a[i] % 2 == 0:
        a[i] //= 2
        cnt += 1
    else:
        if memo != cnt:
            print(0)
            exit()
        cnt = 0
lcm_memo = a[0]
for i in range(1, n):
    lcm_memo = lcm_memo * a[i] // gcd(lcm_memo, a[i])
print(1 + floor((m - lcm_memo) / (lcm_memo * 2)))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from math import floor

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
if n == 1 and a[0] // 2 > m:
    print(0)
    exit()
cumsum = a[0]
for i in range(1, n):
    cumsum = gcd(cumsum, a[i])
for i in range(n):
    a[i] //= cumsum
    if a[i] > m:
        print(0)
        exit()
lcm_memo = a[0]
for i in range(1, n):
    lcm_memo = lcm_memo * a[i] // gcd(lcm_memo, a[i])
if lcm_memo > m:
    print(0)
else:
    print(1 + floor((m - lcm_memo) / (lcm_memo * cumsum)))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from math import floor

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
cumsum = a[0]
for i in range(1, n):
    cumsum = gcd(cumsum, a[i])
for i in range(n):
    a[i] //= cumsum
lcm_memo = a[0]
for i in range(1, n):
    lcm_memo = lcm_memo * a[i] // gcd(lcm_memo, a[i])
if lcm_memo > m:
    print(0)
else:
    print(1 + floor((m - lcm_memo) / (lcm_memo * cumsum)))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from math import floor

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
cumsum = a[0]
for i in range(1, n):
    cumsum = gcd(cumsum, a[i])
for i in range(n):
    a[i] //= cumsum
lcm_memo = a[0]
for i in range(1, n):
    lcm_memo = lcm_memo * a[i] // gcd(lcm_memo, a[i])
if lcm_memo > m:
    print(0)
else:
    print(1 + floor((m - lcm_memo) / (lcm_memo * 2)))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from math import floor

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
cumsum = a[0]
for i in range(1, n):
    cumsum = gcd(cumsum, a[i])
for i in range(n):
    a[i] //= cumsum
lcm_memo = a[0]
for i in range(1, n):
    lcm_memo = lcm_memo * a[i] // gcd(lcm_memo, a[i])
print(floor(m / lcm_memo) - floor(m / (lcm_memo * 2)))

Submission status: Wrong Answer

Solution code:
from functools import reduce
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return (gcd(y, x%y))

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

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

def div_2(n):
    count=0
    while n%2==0:
        n//=2
        count+=1
    return count

n, m = (int(x) for x in input().split())
a = list(map(int, input().split()))
def culc_count(n, m , a):
    di = div_2(a[0])
    for i in range(1,n):
        if div_2(a[i]!=di):
            return 0

    count=0
    for i in range(n):
        a[i]=int(a[i]/2)
    lcm = lcm_list(a)
    m_re = m-lcm
    co = m_re//(2*lcm)
    co+=1
    count=co
    return count

print(culc_count(n, m ,a))

Submission status: Wrong Answer

Solution code:
from functools import reduce
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return (gcd(y, x%y))

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

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

def div_2(n):
    count=0
    while n%2==0:
        n//=2
        count+=1
    return count

n, m = (int(x) for x in input().split())
a = list(map(int, input().split()))
def culc_count(n, m , a):
    di = div_2(a[0])
    for i in range(1,n):
        if a[i]%(pow(2,di))!=0:
            return 0
    count=0
    for i in range(n):
        a[i]=int(a[i]/2)
    lcm = lcm_list(a)
    m_re = m-lcm
    co = m_re//(2*lcm)
    co+=1
    count=co
    return count

print(culc_count(n, m ,a))

Submission status: Wrong Answer

Solution code:
from functools import reduce
def gcd(x,y):
    gcd = 1
    for i in range(2,min(x,y)):
        if x%i==0 and y%i==0:
            gcd=i
    return gcd

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

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

def div_2(n):
    count=0
    while n%2==0:
        n//=2
        count+=1
    return count

n, m = (int(x) for x in input().split())
a = list(map(int, input().split()))
def culc_count(n, m , a):
    di = div_2(a[0])
    for i in range(1,n):
        if a[i]%(pow(2,di))!=0:
            return 0
    count=0
    for i in range(n):
        a[i]=int(a[i]/2)
    lcm = lcm_list(a)
    m_re = m-lcm
    co = m_re//(2*lcm)
    co+=1
    count=co
    return count

print(culc_count(n, m ,a))

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)
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
c=a[0]
dnum=0
while c%2==0:
    dnum+=1
    c=c//2
for i in range(len(a)):
    c=a[0]
    dnum1=0
    while c%2==0:
        dnum1+=1
        c=c//2
    if dnum1!=dnum:
        b=1
        break

#print(a)
if b==1:
    print(0)
else:
    for i in range(len(a)):
        a[i]=a[i]//2
    #print(a)
    amc=lcm_list(a)
    #print(amc)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))

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)
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
if a[0]%2==0:
    for i in range(len(a)):
        if a[i]%2==0:
            a[i]=int(a[i]/2)
        else:
            b=1
            break
if b==1:
    print(0)
else:
    amc=lcm_list(a)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))

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)
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
while a[0]%2==0:
    for i in range(len(a)):
        if a[i]%2==0:
            a[i]=int(a[i]/2)
        else:
            b=1
            break
if b==1:
    print(0)
else:
    amc=lcm_list(a)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))

Submission status: Wrong Answer

Solution code:
import fractions
def lcm_list(numbers):
    answer=numbers[0]
    for number in numbers:
        answer=(answer*number/fractions.gcd(answer,number))
    return answer
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
while a[0]%2==0:
    for i in range(len(a)):
        if a[i]%2==0:
            a[i]=int(a[i]/2)
        else:
            b=1
            break
if b==1:
    print(0)
else:
    amc=lcm_list(a)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))

Submission status: Wrong Answer

Solution code:
import math
def lcm_base(x, y):
    return int((x * y) / math.gcd(x, y))
def lcm_list(numbers):
    answer=numbers[0]
    for number in numbers:
        answer=lcm_base(answer,number)
    return answer
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
while a[0]%2==0:
    for i in range(len(a)):
        if a[i]%2==0:
            a[i]=int(a[i]/2)
        else:
            b=1
            break
if b==1:
    print(0)
else:
    amc=a[0]#lcm_list(a)
    print(int((m+amc)/(2*amc)))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

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

def main():
  # X=ak(p+0.5)
  #  =ak*p+0.5*ak
  # akとpは整数よりak*pは整数
  # 0.5*akが整数になるにはakは偶数（制約の指定もあり）
  # X=(ak/2)*(2p+1)
  # 2p+1は奇数なのでXとak'の2で割れる回数は一致する
  # 2で割れる回数が一致しない例
  # 6と8なら
  # 6,3,9,15,21,27,...
  # 8,4,12,20,28,36,...
  # 一致しない
  # 全体を2^tで割れる（割れないなら0）
  # X'=(ak/2)'*(2p+1)
  # (X'=X/(2^t),(ak/2)'=(ak/2)/(2^t))
  # M/(2^t)以下で
  # (ak/2)'の公倍数を奇数倍したものが何個あるかを数える

  n,m=LI()
  _l=LI()
  l=[x//2 for x in _l]

  x=f(l[0])
  for i in range(n):
    b=l[i]
    if x!=f(b):
      return 0
    l[i]>>=x

  _lcm=1
  for x in l:
    _lcm=lcm(_lcm,x)
    if _lcm>m:
      return 0

  # print(m,_lcm)
  return int((m/_lcm+1)//2)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc150/tasks/abc150_d
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

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

def main():
  # X=ak(p+0.5)
  #  =ak*p+0.5*ak
  # akとpは整数よりak*pは整数
  # 0.5*akが整数になるにはakは偶数（制約の指定もあり）
  # X=(ak/2)*(2p+1)
  # 2p+1は奇数なのでXとak'の2で割れる回数は一致する
  # 2で割れる回数が一致しない例
  # 6と8なら
  # 6,3,9,15,21,27,...
  # 8,4,12,20,28,36,...
  # 一致しない
  # 全体を2^tで割れる（割れないなら0）
  # X'=(ak/2)'*(2p+1)
  # (X'=X/(2^t),(ak/2)'=(ak/2)/(2^t))
  # M/(2^t)以下で
  # (ak/2)'の公倍数を奇数倍したものが何個あるかを数える

  n,m=LI()
  _l=LI()
  l=[x//2 for x in _l]

  x=f(l[0])
  for i in range(n):
    b=l[i]
    if x!=f(b):
      return 0
    l[i]<<=x

  _lcm=1
  for x in l:
    _lcm=lcm(_lcm,x)
    if _lcm>m:
      return 0

  # print(m,_lcm)
  return (m//_lcm+1)//2

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import copy
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)
a_div2 = [0]*len(a)
a2 = copy.deepcopy(a)
for i in range(len(a)):
    if a[i] % 2 == 1:
        print(0)
        exit()
for i in range(len(a)):
    while a2[i] % 2 != 0:
        a2[i] //= 2
        a_div2[i] += 1
if len(set(a_div2)) != 1:
    print(0)
    exit()


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


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


if len(a) == 1:
    if m < a[0]//2:
        print(0)
    else:
        print((m-a[0]//2)//a[0] + 1)
else:
    cnt = 1
    for i in range(len(a)):
        a[i] //= 2
        cnt = lcm(cnt,a[i])
    if m < cnt:
        print(0)
    else:
        print((m-cnt)//(cnt*2)+1)

Submission status: Wrong Answer

Solution code:
import copy
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)
a_div2 = [0]*n
a2 = copy.deepcopy(a)
for i in range(len(a)):
    if a[i] % 2 == 1:
        print(0)
        exit()
for i in range(len(a)):
    while a2[i] % 2 != 0:
        a2[i] //= 2
        a_div2[i] += 1
if len(set(a_div2)) != 1:
    print(0)
    exit()


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


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


if len(a) == 1:
    if m < a[0]//2:
        print(0)
    else:
        print((m-a[0]//2)//a[0] + 1)
else:
    cnt = 1
    for i in range(len(a)):
        a[i] //= 2
        cnt = lcm(cnt,a[i])
    if m < cnt:
        print(0)
    else:
        print((m-cnt)//(cnt*2)+1)

Submission status: Wrong Answer

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

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)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
keta=0
buf=0
while(buf>0):
    buf/=2
    keta+=1
for i in range(n):
    buf=b[i]
    tmp=0
    while(buf>0):
        buf/=2
        tmp+=1
    if(keta!=tmp):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)

Submission status: Wrong Answer

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

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)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
for i in range(n):
    if(b[i]%2!=b[0]%2):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)

Submission status: Wrong Answer

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

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)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
for i in range(n):
    if(b[i]%2!=b[0]%2):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])

if(f==0):
    res=m//x+1
    res//=2
else:
    res=m//x
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)

Submission status: Wrong Answer

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

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

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

if N==1:
    print(0)
    exit()

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)
for i in range(len(a)):
    if a[i] % 2 == 1:
        print(0)
        exit()


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


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


if len(a) == 1:
    if m < a[0]//2:
        print(0)
    else:
        print((m-a[0]//2)//a[0] + 1)
else:
    cnt = 1
    for i in range(len(a)):
        a[i] //= 2
        if a[i] % 2 == 0:
            print(0)
            exit()
        cnt = lcm(cnt,a[i])
    if m < cnt:
        print(0)
    else:
        print((m-cnt)//(cnt*2)+1)

Submission status: Wrong Answer

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

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)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
for i in range(n):
    if(b[i]%2!=b[0]%2):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])

if(f==0):
    res=m//x+1
    res//=2
else:
    res=m/x
#print(x)
if(flag):
    print(0)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
import fractions

N,M = map(int, input().split())
B = list(map(int, input().split()))
A = [i // 2 for i in B]
lcm = 1

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

jdg = lcm
cnt = 0
i = 1

while jdg <= M:
    cnt += 1
    jdg = jdg//(i)*(i+2)
    i += 2 
print(cnt)