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:
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)


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:
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
# print(v[0])
while (v[0] % 2 == 0):
    v[0] //= 2
    num += 1
# print(v[0])
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % (2 ** num) != 0 or v[i + 1] % (2 ** (num + 1)) == 0):
        ans = 2
        break
    # print(v[i+1])
    v[i+1] //= 2**num
    # print(v[i+1])
    ans = lcm(ans, v[i + 1])
# print(ans)
if (ans % 2 == 0):
    print(0)
    exit(0)
ans *= 2**(num-1)
print(ans, m)
print(((m//ans)+1)//2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)
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 *= a[i]
    if m < cnt:
        print(0)
    else:
        print((m-cnt)//(cnt*2)+1)

Submission status: Wrong Answer

Solution code:
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
# print(v[0])
while (v[0] % 2 == 0):
    v[0] //= 2
    num += 1
# print(v[0])
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % (2 ** num) != 0 or v[i + 1] % (2 ** num + 1) == 0):
        ans = 2
        break
    v[i+1] //= 2**num
    ans = lcm(ans, v[i + 1])
# print(ans)
if (ans % 2 == 0):
    print(0)
    exit(0)
ans *= 2**num
print(m//ans)

Submission status: Wrong Answer

Solution code:
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
while (v[0] % 2 != 0):
    v[0] //= 2
    num += 1
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % 2 ** num != 0 or v[i + 1] % 2 ** (num+1) == 0):
        print(0)
        exit(0)
    else:
        v[i+1] //= 2**num
        ans = lcm(ans, v[i + 1])
if (ans % 2 == 0):
    print(0)
    exit(0)

ans *= 2**num
print(m//ans)

Submission status: Wrong Answer

Solution code:
import math


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
while (v[0] % 2 != 0):
    v[0] //= 2
    num += 1
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % 2 ** num != 0 or v[i + 1] % 2 ** (num+1) == 0):
        print(0)
        exit(0)
    else:
        v[i+1] //= 2**num
        ans = lcm(ans, v[i + 1])
if (ans % 2 == 0):
    print(0)
    exit(0)

ans *= 2**num
print(m//ans)

Submission status: Wrong Answer

Solution code:
import math


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
while (v[0] % 2 != 0):
    v[0] //= 2
    num += 1
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % 2 ** num != 0 or v[i + 1] % 2 ** (num+1) == 0):
        print(0)
        exit(0)
    else:
        v[i+1] //= 2**num
        ans = lcm(ans, v[i + 1])
m //= 2**num
print((m+ans-1)//ans)

Submission status: Wrong Answer

Solution code:
import fractions
"""最小公倍数"""
def lcm(a,b):
    f = fractions.gcd(a,b)
    return a*b//f

n,m = map(int,input().split())
A = list(map(int,input().split()))
l = A[0]
for a in A[1:]:
    l = lcm(l, a)

if n==1:
    if l%2!=0:
        print(0)
    else:
        print(1 + int((m-l//2)/l))

else:
    flg = True
    for a in A:
        if (l//a)%2==0:
            flg = False
    if not flg:
        print(0)
    else:
        minx = l//2
        if minx>m:
            print(0)
        else:
            print(1 + m//l)

Submission status: Wrong Answer

Solution code:
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
while (v[0] % 2 != 0):
    v[0] //= 2
    num += 1
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % 2 ** num != 0):
        print(0)
        exit(0)
    v[i+1] //= 2**num
    ans = lcm(ans, v[i + 1])
m //= 2**num
print((m+ans-1)//ans)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for x in a:
    lcm = (lcm*x) // fractions.gcd(lcm, x)
ans = (M // lcm)
if M % lcm >= (lcm//2):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    s = set()
    for i in a:
        k = 0
        while not i&1:
            i >>= 1
            k += 1
        if not k:
            print(0)
            return
        s.add(k)
    if len(s) != 1:
        print(0)
        return
    a = [i >> 1 for i in a]
    g = a[0]
    l = g
    for i in a[1:]:
        ng = gcd(g,i)
        l = g*i//ng
        g = ng
    print((m//l)-(m//(2*l)))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import fractions

"""最小公倍数"""
def lcm(a,b):
    f = fractions.gcd(a,b)
    return a*b//f

n,m = map(int,input().split())
A = list(map(int,input().split()))
l = A[0]
for a in A[1:]:
    l = lcm(l, a)
flg = True
for a in A:
    if (l//a)%2==0:
        flg = False
if not flg:
    print(0)
else:
    minx = l//2
    if minx>m:
        print(0)
    else:
        print(1 + m//l)

Submission status: Wrong Answer

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

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

A = [a // 2 for a in A]
LCM = A[0]
for a in A:
    LCM = lcm(LCM, a)

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

Submission status: Wrong Answer

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

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

A = [a // 2 for a in A]
LCM = A[0]
for a in A:
    LCM = lcm(LCM, a)

ans = -(-(M // LCM) // 2)
print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    s = set()
    for i in a:
        k = 0
        while not i&1:
            i >>= 1
            k += 1
        if not k:
            print(0)
            return
        s.add(k)
    if len(s) != 1:
        print(0)
        return
    a = [i >> 1 for i in a]
    g = a[0]
    l = g
    for i in a[1:]:
        ng = gcd(g,i)
        l = g*i//ng
    print((m//l)-(m//(2*l)))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    for i in a:
        if i&1:
            print(0)
            return
    a = [i >> 1 for i in a]
    g = a[0]
    l = g
    for i in a[1:]:
        ng = gcd(g,i)
        l = g*i//ng
    print((m//l)-(m//(2*l)))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
a = LIST()
l = 1
num2 = 0
for i in range(n):
    if i == 0:
        ibin = bin(a[i])[2:]
        for j in reversed(range(len(ibin))):
            if ibin[j] == '1':
                num2 = len(ibin) - j - 1
                break
        l = a[i]
    else:
        tmp = int(bin(a[i] >> num2)[2:], 2) #2で割る
        if tmp * (2 ** num2) != a[i]:
            print(0)
            exit()
        l = lcm(l, tmp)
    debug(l, num2)
debug(l)
ans = (2 * m // l + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

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


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  c = lcm_list(a)
  if c>10**9 or c%2==0:
    ans = 0
  else:
    ans = (m//c) - (m//(c+c))
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

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


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  c = lcm_list(a)
  if c>m:
    ans = 0
  else:
    ans = (m//c) - (m//(c+c))
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

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


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  b = a%2
  if b.sum() < n:
    ans = 0
  else:
    c = lcm_list(a)
    if c>m:
      ans = 0
    else:
      ans = (m//c) - (m//(c+c))
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

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


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  b = a%2
  if b.sum() < n:
    ans = 0
  else:
    c = lcm_list(a)
    ans = (m//c) - (m//(c+c))
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  b = a%2
  if b.sum() < n:
    ans = 0
  else:
    c = reduce(lcm, a)
    ans = (m+c)//(2*c)
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)


def main():
  n, m = map(int, readline().split())
  a = np.array(input().split(), np.int64)
  a //= 2
  b = a%2
  if b.sum() < n:
    ans = 0
  else:
    c = reduce(lcm, a)
    cnt = 0
    ans = ((m//c) + 1)//2
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = [i//2 for i in map(int, input().split())]
x = 1
for i in a:
    x = (x*i)//gcd(x, i)
result = -(-(m//x)//2)
print(result)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = [i//2 for i in map(int, input().split())]
x = 1
for i in a:
    x = (x*i)//gcd(x, i)
result = (m//x)//2 +((m//x)%2==1)
print(result)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in a:
    x = (x*i)//gcd(x, i)
x //= 2
result = (m//x)//2 +((m//x)%2==1)
print(result)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = a[0]
for i in a[1:]:
    a = gcd(x, i)
    x = (x//a)*(i//a)*a
x //= 2
result = (m//x)//2 +((m//x)%2==1)
print(result)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = a[0]
for i in a[1:]:
    a = gcd(x, i)
    x = (x//a)*(i//a)*a
x //= 2
l, r, result = 0, 10**18, 0
i = (r+l)//2
while l<r:
    if x*(2*i+1) <= m:
        l = i+1
    else:
        r = i
    i = (r+l)//2
print(r)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = a[0]
for i in a[1:]:
    a = gcd(x, i)
    x = (x//a)*(i//a)*a
x //= 2
l, r, result = 0, 10**18, 0
i = (r+l)//2
while l<r:
    if x*(2*i+1) < m:
        l = i+1
    else:
        r = i
    i = (r+l)//2
print(r)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = a[0]
for i in a[1:]:
    a = gcd(x, i)
    x = (x//a)*(i//a)*a
x //= 2
l, r, result = 0, 10**9, 0
i = (r+l)//2
while l<r:
    if x*(2*i+1) < m:
        l = i+1
    else:
        r = i
    i = (r+l)//2
print(r)

Submission status: Wrong Answer

Solution code:
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:
def gcd(n,m):
    n,m=sorted([n,m])
    while(m%n!=0):
        n,m=m%n,n
    return n
def lcm(n,m):
    return n*m//gcd(n,m)
n,m=map(int,input().split())
l=list(map(int,input().split()))
t=l[0]//2
for i in l[1:]:
    t=lcm(t,i//2)
if 0 in [i%4 for i in l]:
    print(0)
else:
    print(-(-(m//t)//2))

Submission status: Wrong Answer

Solution code:
def gcd(n,m):
    n,m=sorted([n,m])
    while(m%n!=0):
        n,m=m%n,n
    return n
def lcm(n,m):
    return n*m//gcd(n,m)
n,m=map(int,input().split())
l=list(map(int,input().split()))
t=l[0]//2
for i in l[1:]:
    t=lcm(t,i//2)
print(-(-(m//t)//2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a_li = list(map(int, input().split()))
# すべてのaを2で割る
a_li = [a // 2 for a in a_li]

from fractions import gcd
from math import ceil

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

def even_or_odd(a):
    parity = 'even' if a % 2 == 0 else 'odd'
    return parity

# a_lcm: aの最小公倍数, parity: すべてのaの偶奇性
a_lcm = 1
parity = even_or_odd(a_li[0])

# a_lcmを求める
for a in a_li:
    a_lcm = lcm(a, a_lcm)
    # 偶奇が不一致、またはa_lcmがm以上の場合答えなし
    if parity != even_or_odd(a) or a_lcm > m:
        parity = 'irregular'
        break

# 先程弾いた場合と、lcmとaの偶奇性の不一致で答えなし
if parity == 'irregular' or even_or_odd(a_lcm) != parity:
    ans = 0
else:
    ans = m // a_lcm
    ans = ceil(ans / 2)

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a_li = list(map(int, input().split()))
# すべてのaを2で割る
a_li = [a // 2 for a in a_li]

from fractions import gcd

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

def even_or_odd(a):
    parity = 'even' if a % 2 == 0 else 'odd'
    return parity

# a_lcm: aの最小公倍数, parity: すべてのaの偶奇性
a_lcm = 1
parity = even_or_odd(a_li[0])

# a_lcmを求める
for a in a_li:
    a_lcm = lcm(a, a_lcm)
    # 偶奇が不一致、またはa_lcmがm以上の場合答えなし
    if parity != even_or_odd(a) or a_lcm > m:
        parity = 'irregular'
        break

# 先程弾いた場合と、lcmとaの偶奇性の不一致で答えなし
if parity == 'irregular' or even_or_odd(a_lcm) != parity:
    ans = 0
else:
    ans = m // a_lcm
    ans = ans // 2 + ans % 2

print(ans)

Submission status: Wrong Answer

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

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

def even_or_odd(a):
    a_parity = 'even' if a % 2 == 0 else 'odd'
    return a_parity

a_lcm = 1
a_parity = even_or_odd(a_li[0])
for a in a_li:
    if a_parity != even_or_odd(a):
        a_parity = 'irregular'
        break
    a_lcm = lcm(a, a_lcm)
lcm_parity = even_or_odd(a_lcm)
if a_parity == 'irregular' or a_lcm > m or a_parity != lcm_parity:
    ans = 0
else:
    ans = m // a_lcm
    ans = ans // 2 + 1 if ans % 2 == 1 else ans // 2
print(ans)

Submission status: Wrong Answer

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

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

def even_or_odd(a):
    parity = 'even' if a % 2 == 0 else 'odd'
    return parity

a_lcm = 1
parity = even_or_odd(a_li[0])
flag = False
for a in a_li:
    if parity != even_or_odd(a):
        flag = True
        break
    a_lcm = lcm(a, a_lcm)

if flag or a_lcm > m:
    ans = 0
elif parity == 'even':
    if a_lcm % 2 == 0:
        ans = m // a_lcm
    else:
        ans = 0
else:
    ans = m // a_lcm
    if a_lcm % 2 == 0:
        ans = ans // 2
    else:
        ans = ans // 2 + 1 if ans % 2 == 1 else ans // 2
print(ans)

Submission status: Wrong Answer

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

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

def even_or_odd(a):
    parity = 'even' if a % 2 == 0 else 'odd'
    return parity

a_lcm = 1
parity = even_or_odd(a_li[0])
flag = False
for a in a_li:
    if parity != even_or_odd(a):
        flag = True
        break
    a_lcm = lcm(a, a_lcm)

if flag:
    ans = 0
elif parity == 'even':
    if a_lcm % 2 == 0:
        ans = m // a_lcm
    else:
        ans = 0
else:
    ans = m // a_lcm
    if a_lcm % 2 == 0:
        ans = ans // 2
    else:
        ans = ans // 2 + 1 if ans % 2 == 1 else ans // 2
print(ans)

Submission status: Wrong Answer

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

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

a_lcm = 1
for a in a_li:
    a_lcm = lcm(a, a_lcm)

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

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
    kotae_2 =0
elif M_2 < saisyou_koubaisu_2:
    kotae = 0
else:
    kotae_2 = M_2 //saisyou_koubaisu_2  # Mの中で半公倍数を数える
    kotae = (kotae_2 +1)  # 偶数は除く

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
    kotae_2 =0
elif M_2 < saisyou_koubaisu_2:
    kotae = 0
else:
    kotae_2 = M //saisyou_koubaisu_2  # Mの中で半公倍数を数える
    kotae = (kotae_2 +1)//2  # 偶数は除く
print(kotae)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
    kotae_2 =0
elif M < saisyou_koubaisu_2:
    kotae = 0
else:
    kotae_2 = M //saisyou_koubaisu_2  # Mの中で半公倍数を数える
    kotae = (kotae_2 +1)//2  # 偶数は除く
print(kotae)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
    kotae_2 =0
else:
    kotae_2 = M //saisyou_koubaisu_2  # Mの中で半公倍数を数える
    kotae = (kotae_2 +1)//2  # 偶数は除く
print(kotae)