Problem: 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).

Submission attempts (in order):
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(tmp // 2 + 1)
else:
    print(0)

import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(tmp // 2 + 1)
else:
    print(tmp // 2)

import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(round(tmp // 2) + 1)
else:
    print(tmp // 2)

import sys
import fractions
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]

ans = 0
half_lcm = lcm_list(a) // 2

a = set(a)
for i in range(half_lcm, M+1, half_lcm):
    if all(int((i / x * 2)) & 1 for x in set(a)):
        ans += 1

print(ans)

import sys
import fractions
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]

ans = 0
half_lcm = lcm_list(a) // 2

a = set(a)
for i in range(half_lcm, M+1, half_lcm):
    if all(int((i / x * 2)) & 1 for x in a):
        ans += 1

print(ans)

import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(tmp + 1 // 2)
else:
    print(0)

import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

print(round(M / half_lcm / 2))


import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2
if half_lcm > M:
    print(0)
    exit()

print(round(M / half_lcm / 2))


import sys
# import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
stdin = sys.stdin

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

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

def lcm_list(l):
    return reduce(lcm, l, 1)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
a = i_l()
half_lcm = lcm_list(a) // 2

for i in a:
    if half_lcm // (i // 2) % 2 == 0:
        print(0)
        exit()

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Time Limit Exceeded

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted