Problem:


Score : 400 points

Problem Statement

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

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

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

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

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

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

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

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

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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


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


for i in a:
    if i % 2 == 0:
        print(0)
        sys.exit()
LCM = a[0]
if LCM > M:
    print(0)
    sys.exit()

for i in range(N - 1):
    LCM = lcm(a[i], a[i + 1])

ans = math.floor((M / LCM - 1) / 2) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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


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


LCM = a[0]
if LCM > M:
    print(0)
    sys.exit()

for i in range(N - 1):
    LCM = lcm(a[i], a[i + 1])

ans = math.floor((M / LCM - 1) / 2) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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


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


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

ans = math.floor((M / LCM - 1) / 2) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce


def count_factors(a, factor):
    count = 0
    while a % factor == 0:
        count += 1
        a //= factor
    return count


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


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


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(set([int(v) >> 1 for v in input().split()]))
    num_of_two = count_factors(a[0], 2)
    for ai in a[1:]:
        if count_factors(ai, 2):
            print(0)
            exit()

    a_lcm = reduce(lambda x, y: lcm(x, y), a)
    if a_lcm > m:
        print(0)
        exit()

    print((m // a_lcm + 1) // 2)

Submission status: Wrong Answer

Solution code:
from math import ceil
from fractions import gcd


def prime_factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    twos_cnt = {prime_factor(num).count(2) for num in a}
    if len(twos_cnt) > 1:
        print(0)
        exit()

    num_two = twos_cnt.pop()
    a_div = [x >> num_two for x in a]

    a_div_lcm = a_div[0]
    for i in range(1, n):
        a_div_lcm = a_div_lcm * a_div[i] // gcd(a_div_lcm, a_div[i])
    print(ceil(m / a_div_lcm * 0.5 - 0.5))

Submission status: Wrong Answer

Solution code:
from math import ceil


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


def prime_factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    twos_cnt = {prime_factor(num).count(2) for num in a}
    if len(twos_cnt) > 1:
        print(0)
        exit()

    num_two = twos_cnt.pop()
    a_div = [x >> num_two for x in a]

    a_div_lcm = a_div[0]
    for i in range(1, n):
        a_div_lcm = a_div_lcm * a_div[i] // gcd(a_div_lcm, a_div[i])
    print(ceil(m / a_div_lcm * 0.5 - 0.5))

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
    
  query = [0]*n
  for i in range(n):
    tmp = a[i]*2
    while tmp%2 == 0:
      tmp //= 2
      query[i] += 1
  if len(set(query)) != 1:
    print(0)
    exit()
    
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)

  print(math.ceil(m/(g*2)))
  
solve()

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
    
  query = [0]*n
  for i in range(n):
    tmp = a[i]*2
    while tmp%2 == 0:
      tmp //= 2
      query[i] += 1
  if len(set(query)) != 1:
    print(0)
    exit()
    
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)
    if g > m:
      print(0)
      exit()

  print(math.ceil(m/(g*2)))
  
solve()

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
    
  query = [0]*n
  for i in range(n):
    tmp = a[i]*2
    while tmp%2 == 0:
      tmp //= 2
      query[i] += 1
  if len(set(query)) != 1:
    print(0)
    exit()
    
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)
    if g > m:
      print(0)
      exit()

  print(math.ceil(m/(g*2*max(query))))
  
solve()

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
    
  query = [0]*n
  for i in range(n):
    tmp = a[i]*2
    while tmp%2 == 0:
      tmp //= 2
      query[i] += 1

    
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)
    if g > m:
      print(0)
      exit()

  print(math.ceil(m/(g*2*max(query))))
  
solve()

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
    
  query = [0]*n
  for i in range(n):
    tmp = a[i]*2
    while tmp%2 == 0:
      tmp //= 2
      query[i] += 1

    
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)
    if g > m:
      print(0)
      exit()

  print(math.ceil(m/(g*max(query))))
  
solve()

Submission status: Wrong Answer

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

import math
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  for i in range(n):
    a[i] //= 2
  g = 1
  for i in range(n):
    tmp = a[i]
    g = lcm(tmp,g)
    if g > m:
      print(0)
      exit()

  print(math.ceil(m/(g*2)))
  
solve()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd
def Lcm(x):
  L = 1
  for a in x:
    a=a//2
    L = (a // gcd(a, L))*L
  return L
X=Lcm(A)
fg = 0
for i in A:
  if (X//i)%2==0:
    fg=1
    break
if fg==1:
  print(0)
else:
  print(((M//X)+1)//2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd
def Lcm(x):
  L = 1
  for a in x:
    a=a//2
    L = (a // gcd(a, L))*L
  return L
X=Lcm(A)
fg = 0
for i in A:
  if (X//i)%2==0:
    fg=1
    break
if fg==0:
  print(0)
else:
  print((M//X+1)//2)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

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

n,m,*aaa = get_all_int()

x = reduce(lcm, aaa)
x = x//2

if x > m:
    print(0)
    exit()

ans = m // x
ans = (ans+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

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

n,m,*aaa = get_all_int()
m *= 2

x = reduce(lcm, aaa)

if x > m:
    print(0)
    exit()

ans = m // x
ans = (ans+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

"""
A = [a_0, a_1, ...]として、
X = a_i * (p+0.5) = (a_i//2) * (2*p+1)
(2p+1)は奇数より、Xが2で割り切れる回数は(a_i//2)が2で割り切れる回数に等しい。
特に全てのa_iに関して2で割り切れる回数が等しくなければXは存在しない。

もし全てのa_iに関して2で割り切れる回数が等しいならば、
    T = LCM(a_0//2, a_1//2, ...)
と定めれば、XはTの奇数倍で尽くされる。
"""

def quotBy2(n):
    num = 0
    while n % 2 == 0:
        num += 1
        n //= 2
    return num

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

T = A[0] // 2
quot = quotBy2(A[0])
for i in range(N - 1):
    T = lcm(A[i]//2, A[i + 1]//2)
    #print("T={}".format(T))
    if quot != quotBy2(A[i + 1]):
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

"""
A = [a_0, a_1, ...]として、
X = a_i * (p+0.5) = (a_i//2) * (2*p+1)
(2p+1)は奇数より、Xが2で割り切れる回数は(a_i//2)が2で割り切れる回数に等しい。
特に全てのa_iに関して2で割り切れる回数が等しくなければXは存在しない。

もし全てのa_iに関して2で割り切れる回数が等しいならば、
    T = LCM(a_0//2, a_1//2, ...)
と定めれば、XはTの奇数倍で尽くされる。
"""

def quotBy2(n):
    num = 0
    while n % 2 == 0:
        num += 1
        n //= 2
    return num

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

T = A[0] // 2
quot = quotBy2(A[0])
for i in range(N - 1):
    T = lcm(A[i]//2, A[i + 1]//2)
    print("T={}".format(T))
    if quot != quotBy2(A[i + 1]):
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

"""
A = [a_0, a_1, ...]として、
X = a_i * (p+0.5) = (a_i//2) * (2*p+1)
(2p+1)は奇数より、Xが2で割り切れる回数は(a_i//2)が2で割り切れる回数に等しい。
特に全てのa_iに関して2で割り切れる回数が等しくなければXは存在しない。

もし全てのa_iに関して2で割り切れる回数が等しいならば、
    T = LCM(a_0//2, a_1//2, ...)
と定めれば、XはTの奇数倍で尽くされる。
"""

def quotBy2(n):
    num = 0
    while n % 2 == 0:
        num += 1
        n //= 2
    return num

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

quotientOf2 = 1
T = A[0]
quot = quotBy2(A[0])
for i in range(N - 1):
    T = lcm(A[i]//2, A[i + 1]//2)
    #print("T={}".format(T))
    if quot != quotBy2(A[i + 1]):
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

"""
A = [a_0, a_1, ...]として、
X = a_i * (p+0.5) = (a_i//2) * (2*p+1)
(2p+1)は奇数より、Xが2で割り切れる回数は(a_i//2)が2で割り切れる回数に等しい。
特に全てのa_iに関して2で割り切れる回数が等しくなければXは存在しない。

もし全てのa_iに関して2で割り切れる回数が等しいならば、
    T = LCM(a_0//2, a_1//2, ...)
と定めれば、XはTの奇数倍で尽くされる。
"""

def quotBy2(n):
    num = 0
    while n % 2 == 0:
        num += 1
        n //= 2
    return num

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

quotientOf2 = 1
T = A[0]
quot = quotBy2(A[0])
for i in range(N - 1):
    T = lcm(A[i]//2, A[i + 1]//2)
    #print("T={}".format(T))
    if quot != quotBy2(A[i + 1]):
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

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

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    a_lcm = 1
    for a in A:
        d = gcd(a_lcm, a)
        a_lcm = a_lcm * a // d
        if a_lcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()

Submission status: Wrong Answer

Solution code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    a_lcm = 1
    for a in A:
        d = gcd(a_lcm, a)
        a_lcm = a_lcm * a // d
        if a_lcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()

Submission status: Wrong Answer

Solution code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    if N == 1:
        a_lcm = A[0]
    else:
        a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()

Submission status: Wrong Answer

Solution code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)
    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) for v in input().split()]))

    def calc(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    min_a = reduce(lambda v1, v2: v1 // 2 * v2 //
                   2 // calc(v1 // 2, v2 // 2), A)

    if M < min_a:
        print(0)
    else:
        print((M - min_a) // (min_a * 2) + 1)


main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) for v in input().split()]))

    def calc(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    min_a = reduce(lambda v1, v2: v1 // 2 * v2 //
                   2 // calc(v1 // 2, v2 // 2), A)

    if M * 2 < min_a:
        print(0)
    else:
        print((M - min_a) // (min_a * 2) + 1)


main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) for v in input().split()]))

    def calc(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    min_a = reduce(lambda v1, v2: v1 * v2 // calc(v1, v2), A)

    if M * 2 < min_a:
        print(0)
    else:
        print(round((M - min_a / 2) // min_a + 1))


main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) for v in input().split()]))

    def calc(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    min_a = reduce(lambda v1, v2: v1 * v2 // calc(v1, v2), A)
    h_min_a = min_a // 2

    if M < h_min_a:
        print(0)
    else:
        print((M - min_a // 2) // min_a + 1)


main()

Submission status: Wrong Answer

Solution code:
#author: dokueki

#author: dokueki

import fractions




def find_lcm(num1, num2):
    return (num1*num2)/fractions.gcd(num1, num2)


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

if n == 1:
    if l[0]/2 > m:
        print(0)
    else:
        print(1)
else:

    num1 = l[0]
    num2 = l[1]
    lcm = find_lcm(num1, num2)

    for i in range(2, len(l)):
        lcm = find_lcm(lcm, l[i])

    print(round(m/lcm))

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
x = a[0] / 2
for i in range(n - 1):
    x = lcm(x, a[i + 1] / 2)
y = 2 * x
while True:
    if (m - x) % y == 0:
        ans = ((m - x) // y) + 1
        break
    if m < x:
        ans = 0
        break
    m -= 1
print(int(ans))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,M = LMIIS()
    A =  list(set(map(lambda x: int(x)//2 ,input().split())))
    # print(A)
    from fractions import gcd
    a = A[0]
    g = a
    x = len(bin(a))-len(bin(a).rstrip('0'))
    for a in A:
        # print(bin(a),len(bin(a))-len(bin(a).rstrip('0')))
        if x != len(bin(a))-len(bin(a).rstrip('0')):
            print(0)
            return
        g = gcd(g,a)
    lcm = g
    for a in A:
        lcm *= a
        lcm //= g
    print(((M+lcm)//lcm)//2)
    

    

    



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,M = LMIIS()
    A =  list(set(map(lambda x: int(x)//2 ,input().split())))
    # print(A)
    from fractions import gcd
    a = A[0]
    g = a
    x = len(bin(a))-len(bin(a).rstrip('0'))
    for a in A:
        if x != len(bin(a))-len(bin(a).rstrip('0')):
            print(0)
            return
        g = gcd(g,a)
    lcm = g
    for a in A:
        lcm *= a
        lcm //= g
    if lcm > M:
        print(0)
    else:
        print((M-lcm)//(lcm*2)+1)

    

    

    



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions as fr
from functools import reduce
def lcm_func(x, y):
    return (x * y) // fr.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_func, numbers, 1)
N, M = map(int, input().split())
L = np.array(list(map(int, input().split())))
L_s = L * 1/2
L_S = L_s.tolist()
MB = lcm(*L_S)
Ans = M / MB
if Ans < 1:
  print(0)
else:
  print(int(Ans/2)+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions as fr
from functools import reduce
def lcm_func(x, y):
    return (x * y) // fr.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_func, numbers, 1)
N, M = map(int, input().split())
L = np.array(list(map(int, input().split())))
L_s = L * 1/2
L_S = L_s.tolist()
MB = lcm(*L_S)
Ans = M / MB
print(int(int(Ans)/2)+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

def compute_lcm(a):
  lcm = a[0]
  for i in range(1,len(a)):
    lcm = (lcm * a[i]) // fractions.gcd(lcm, a[i])
  return lcm

lcm = compute_lcm(B)

Tn = M // lcm
if Tn == 0:
  print(0)
elif any([(lcm//b)%2==0 for b in B]):
  print(0)
else:
  print((2*M//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions

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

def compute_lcm(a):
  lcm = a[0]
  for i in range(1,len(a)):
    lcm = (lcm * a[i]) // fractions.gcd(lcm, a[i])
  return lcm

lcm = compute_lcm(B)

Tn = M // lcm
if Tn == 0:
  print(0)
elif any([(lcm//b)%2==0 for b in B]):
  print(0)
elif Tn % 2 == 0:
  print(Tn)
elif Tn % 2 == 1:
  print(Tn // 2 + 1)

Submission status: Wrong Answer

Solution code:
import fractions

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

def compute_lcm(a):
  lcm = a[0]
  for i in range(1,len(a)):
    lcm = (lcm * a[i]) // fractions.gcd(lcm, a[i])
  return lcm

lcm = compute_lcm(B)

Tn = M // lcm
if Tn == 0:
  print(0)
elif any([lcm%b==0 for b in B]):
  print(0)
elif Tn % 2 == 0:
  print(Tn)
elif Tn % 2 == 1:
  print(Tn // 2 + 1)

Submission status: Wrong Answer

Solution code:
import fractions

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

def compute_lcm(a):
  lcm = a[0]
  for i in range(1,len(a)):
    lcm = (lcm * a[i]) // fractions.gcd(lcm, a[i])
  return lcm

lcm = compute_lcm(B)

Tn = M // lcm
if Tn == 0:
  print(0)
elif Tn % 2 == 0:
  print(Tn)
elif Tn % 2 == 1:
  print(Tn // 2 + 1)

Submission status: Wrong Answer

Solution code:
import fractions

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

def compute_lcm(a):
  lcm = a[0]
  for i in range(1,len(a)):
    lcm = (lcm * a[i]) // fractions.gcd(lcm, a[i])
  return lcm

lcm = compute_lcm(B)

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

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [ai/2 for ai in A]

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[n] = 1

    return arr

lcb_dict = {}
for b in B:
  b_dict = factorization(b)
  for key in b_dict.keys():
    if key not in lcb_dict:
      lcb_dict[key] = b_dict[key]
    else:
      lcb_dict[key] = max(b_dict[key], lcb_dict[key])
lcb = 1
for key in lcb_dict.keys():
  lcb *= key**lcb_dict[key]

Xn = 0
Tn = M // lcb
print(int(Tn // 2 if Tn % 2 == 0 else Tn // 2 + 1))

Submission status: Wrong Answer

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

Q = 2 ** 35

two_count = fractions.gcd(a_array[0], Q)
lcm = 1

for a in a_array:
    aa = a // 2
    if two_count != fractions.gcd(a, Q):
        print(0)
        exit()
    lcm = int(aa * lcm) / fractions.gcd(aa, lcm)
    if lcm > M:
        print(0)
        exit()

# ans = ((M//lcm)+1) // 2
ans = (M-lcm) // (2*lcm) + 1
print(int(ans))

Submission status: Wrong Answer

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

Q = 2 ** 35

two_count = fractions.gcd(a_array[0], Q)
lcm = 1

for a in a_array:
    aa = a / 2
    if two_count != fractions.gcd(a, Q):
        print(0)
        exit()
    lcm = int(aa * lcm) / fractions.gcd(aa, lcm)
    if lcm > M:
        print(0)
        exit()

# ans = ((M//lcm)+1) // 2
ans = (M-lcm) // (2*lcm) + 1
print(int(ans))

Submission status: Wrong Answer

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

Q = 2 ** 30

two_count = fractions.gcd(a_array[0], Q)
lcm = 1

for a in a_array:
    aa = a / 2
    if two_count != fractions.gcd(a, Q):
        print(0)
        exit()
    lcm = aa * lcm / fractions.gcd(aa, lcm)
    if lcm > M:
        print(0)
        exit()

ans = ((M//lcm)+1) // 2

print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
a = [int(i/2) for i in a]
num_gcd = a[0]
for i in range(1, n):
    num_gcd = num_gcd * a[i] // fractions.gcd(num_gcd, a[i])
print(round((m // num_gcd) / 2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[ i //2 for i in list(map(int,input().split()))]
def f(x):
  c=0
  while(x%2==0):
    x//=2
    c+=1
  return c
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(a,b):
  return a//gcd(a,b)*b

t=f(a[0])
for i in range(len(a)):
  if t!=f(a[i]):
    exit(0)
  a[i]//=2**t
m//=2**t
l=1
for i in a:
  l=lcm(l,i)
  if l>m:
    print(0)
    exit(0)
m//=l
print((m+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
import math
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
a = [int(i/2) for i in a]
num_gcd = a[0]
for i in range(1, n):
    num_gcd = num_gcd * a[i] // fractions.gcd(num_gcd, a[i])
print(math.ceil((m // num_gcd) / 2))

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections
n,m=map(int,input().split())
a=np.array(list(map(int,input().split())))
a=np.sort(a)
m//=a[0]

l=[]
for p in range(m):
  for i in (a*(p+0.5)):
    if i>m:continue
    if i==int(i):
      l.append(int(i))
print(list(collections.Counter(l).values()).count(len(a)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections
n,m=map(int,input().split())
a=np.array(list(map(int,input().split())))
a=np.sort(a)
m//=a[0]

l=[]
for p in range(m):
  print((a*(p+0.5)))
  for i in (a*(p+0.5)):
    if i>m:continue
    if i==int(i):
      l.append(int(i))
print(list(collections.Counter(l).values()).count(len(a)))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = set(map(int, input().split()))

d = {}
for a in A:
  x = a // 2 + a
  d[str(x)] = d.setdefault(str(x), 0) + 1
  while 1:
    x += a
    if x > m:
      break
    d[str(x)] = d.setdefault(str(x), 0) + 1
ans = 0
for val in d.values():
  if val == len(A):
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
a_array = list(map(int,input().split()))
q = 2 ** 30 

lcm = 1
two = fractions.gcd(a_array[0]/2,q)
for a in a_array:
    a = a / 2
    if two != fractions.gcd(a,q):
        print(0)
        exit()
    lcm = a * lcm / fractions.gcd(a,lcm)
    if lcm > M:
        print(0)
        exit()
# print(lcm)

m_max = M // lcm

print(int((m_max+1)//2))

Submission status: Wrong Answer

Solution code:
import fractions
import sys
input = sys.stdin.readline

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

lcm = 1
for a in a_array:
    a = a / 2
    lcm = a * lcm / fractions.gcd(a,lcm)
    if lcm > M:
        print(0)
        exit()
# print(lcm)

for a in a_array:
    p = lcm / (a / 2)
    if p % 2 == 0:
        print(0)
        exit()

m_max = M // lcm

print(int((m_max+1)//2))

Submission status: Wrong Answer

Solution code:
import fractions
import sys
input = sys.stdin.readline

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

lcm = 1
for a in a_array:
    a = a / 2
    lcm = a * lcm / fractions.gcd(a,lcm)
# print(lcm)

for a in a_array:
    p = lcm / (a / 2)
    if p % 2 == 0:
        print(0)
        exit()

m_max = M // lcm

print(int((m_max+1)//2))

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from collections import deque
input = sys.stdin.readline

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

lcm = 1
for a in a_array:
    a = a / 2
    lcm = a * lcm / fractions.gcd(a,lcm)
# print(lcm)

for a in a_array:
    p = lcm / (a / 2)
    if p % 2 == 0:
        print(0)
        exit()

m_max = M // lcm

print((m_max+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

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

total = M // l
total += total & 1
print(total // 2)