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 functools

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

def multiple(a, b):
    return a*b // euclid(a, b)

def lcm(nums):
        return functools.reduce(multiple, nums)

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [i//2 for i in a]
lcm = lcm(b)
i=1
count=0
if m >= lcm:
    m-=lcm
    count = m//(lcm*2) + 1
print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

n = -1
for v in iter(map(int, input().split())):
    if n == -1:
        n = v
    else:
        n = lcm(n, v)

print(n)

Submission status: Wrong Answer

Solution code:
import fractions
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


n,m = LI()
a = LI()

lcm = a[0]
for i in range(1,n):
    lcm = lcm * a[i] // fractions.gcd(lcm,a[i])
print((m//(lcm//2))-(m//lcm))

Submission status: Wrong Answer

Solution code:
import itertools
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
tmp=lcm_list(A)
print(tmp)
if M>tmp:
    print((M-tmp//2)//tmp+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from itertools import count, accumulate

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

ans = []
for b in map(lambda x: x // 2, A):
    tmp = []
    for p in count(start=1):
        X = b * (2 * p + 1)
        if 1 <= X <= M:
            tmp.append(X)
        else:
            break
    ans.append(tmp)

print(len(list(accumulate(map(set, ans), set.intersection))[-1]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = map(int, input().split())
A = sorted(A, reverse=True)

hankou = []
p = 5
max_a = A[0]
while p <= M:
    hankou.append(max_a * p)
    p += 10

for a in A[1:]:
    hankou = [h for h in hankou if (h / a) % 10 != 0 and (h / a) % 5 == 0]

print(len(hankou))

Submission status: Wrong Answer

Solution code:
import fractions

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

lcm = a_list[0]

for i in range(1, n):
    lcm = lcm * a_list[i] // fractions.gcd(lcm, a_list[i])

print((m-lcm//2)//lcm+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

min_half_lcm = lcm_list(a)//2
tmp = (M // min_half_lcm) // 2

if tmp == 0:
    print(tmp)
else:
    print(tmp+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted([int(x)//2 for x in input().strip().split()])

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

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

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_)

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

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
_a = list(map(lambda x: math.floor(int(x)/2), input().split()))
a = []
for i in _a:
    if not(i in a):
        a.append(i)

count = 0
flag = True

for i in range(1, M):
    flag = True
    for j in range(len(a)):
        if((i%a[j])!=0)or(math.floor(i/a[j])%2==0):
            flag = False
            break
    if(flag):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)

             
def multi_lcm(array, m):
    """arrayのLCMを求める"""
    ans = array[0] 
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
        if ans > 3*m:
            return 3*m
    return ans 

import sys
input = sys.stdin.readline

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

l = [0] * n
for i in range(n):
    cnt = 0
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            cnt += 1
            tmp //= 2
        else:
           break
    l[i] = cnt
if max(l) != min(l):
    print(0)
    exit()
    
div = multi_lcm(a, m)
ans = 0
if m - div // 2 >= 0:
    ans += 1
m = m - div // 2 
ans += m // div
if m < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))
n,m = words(int)
xs = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

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

xs.sort()
xs = list(set(xs))
lcms = 1
plus = 1
for x in xs:
    lcms = lcm(lcms,x)
    plus *= x // 2

#print(lcms,plus)
print((m + plus) // (lcms))

Submission status: Wrong Answer

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

sA=list(set(A))
for i in range(len(sA)):
    while sA[i]%2==0:
        sA[i]//=2
ssA=list(set(sA))

import fractions
lcm=ssA[0]
for i in range(1, len(ssA)):
    lcm = lcm * ssA[i] // fractions.gcd(lcm, ssA[i])
n = M//lcm
if n%2==0:
    print(n//2)
else:
    print(n//2+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce
from fractions import gcd

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

def main():
    N,M = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = np.array(a)
    
    m = A // 2
    lcm = reduce(lcm_base, m, 1)
    #print(lcm)
    
    print(int((M / lcm + 1) / 2))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

N, M = MAP()
A = LIST()

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

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ans//2)

Submission status: Wrong Answer

Solution code:
import fractions

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

nums.sort()

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

print((M * 2) // (lcm(nums[0], nums[-1])) - (M * 2) // ((lcm(nums[0], nums[-1])) * 2)) if lcm(nums[0], nums[-1])  <= (M * 2) else print(0)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
B = [e//2 for e in A]
s = lcm_list(A)
s_b = lcm_list(B)
x = s-s_b
if x > M:
    print(0)
else:
    print((M-x)//s+1)

Submission status: Wrong Answer

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

LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


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

b = [x // 2 for x in a]
c = [x % 2 == 0 for x in b]
d = [x % 2 == 1 for x in b]
dprint(b)
dprint(c, d)


if not all(c) and not all(d):
  print(0)
  exit()

# pro = 1
# for x in b:
#   pro *= x

# import fractions
# gcd = 0
# for x in b:
#   gcd = fractions.gcd(gcd, x)
# dprint('gcd','=',gcd)

# lcm = pro // gcd

# https://note.nkmk.me/python-gcd-lcm/

import math
from functools import reduce
import fractions


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


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


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


lcm = lcm_list(b)

dprint('lcm', '=', lcm)

import math
print(math.ceil(m // lcm / 2))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = [x for x in map(int, input().split())]
sett = set(a)
lst = []

for i in range(len(sett)):
  x = 0
  p = 0
  while x <= m:
    x = int(a[i]*(p+0.5))
    if x > m:
      break
    lst.append(x)
    p += 1

res = []
for i in lst:
  if lst.count(i) == len(sett):
    res.append(i)
ans = set(res)
print(len(ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N, M = [int(x) for x in input().split()]
    a = np.sort(np.unique(np.array([int(x) for x in input().split()]) // 2))[::-1]
    b = [a[0]]
    for i in range(1, len(a)):
        flag = False
        for x in b:
            if x % a[i] == 0:
                flag = True
                break
        if not flag:
            b.append(a[i])
    # print(b)
    y = 1
    for x in b:
        # print(b)
        y *= x
    z = M // y
    # print(y, z*y)
    ret = z // 2 if z % 2 == 0 else z // 2 + 1
    print(ret)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

L=a[0]
L2=a[0]
for i in range(1,n):
  L=lcm(L,a[i])
  if L>=10**9+1:
    print(0)
    sys.exit()
  L2=fractions.gcd(L2,a[i])

if L2!=1:
  print(0)
  sys.exit()
if (m//L)%2==0:
  print((m//L)//2)
else:
  print(((m//L)//2)+1)

Submission status: Wrong Answer

Solution code:
import fractions


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


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

x = A[0]

for a in A:
    x = lcm(x, a)

m -= x//2
ans = m // x + bool(m%x)

print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
kouho=[]
for i in A:
    j=1
    while i*(j+0.5)<=M:
        kouho.append(i*(j+0.5))
        j+=1    
#print(kouho)
count = 0
KK = list(set(kouho))
for k in KK:
    if kouho.count(k) == N:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from fractions import gcd

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

@mt
def slv(N, M, A):
    b = A[0] % 4
    for a in A:
        if a % 4 != b:
            error_print('a')
            return 0
    A = set(A)
    d = reduce(gcd, A)
    d = reduce(lambda x, y: x//d * y, A)
    ans = 0
    if M - d//2 > 0:
        ans = (M-d//2) // d
    if d // 2 < M:
        ans += 1

    return ans


def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))
    # for i in [14, 40]:
    #     a = []
    #     for j in range(20):
    #         a.append(int(i*(j+0.5)))
    #     print(i, a)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
'''input
5 1000000000
6 6 2 6 2
'''
# A coding delight
from sys import stdin, stdout
import gc
from copy import deepcopy
from itertools import permutations
gc.disable()
input = stdin.readline
import math


def myfunc(num):
	return num//2

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

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

def lcm(l):
	if len(l) == 1:
		return l[0]
	num1 = l[0] 
	num2 = l[1] 
	lcm = find_lcm(num1, num2) 
	  
	for i in range(2, len(l)): 
	    lcm = find_lcm(lcm, l[i])
	return lcm

# main starts
n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr = list(map(myfunc, arr))
num = lcm(arr)

if num % 2 == 1:
	# print(num)
	if num > m:
		print(0)
	else:
		k = m//num
		if k % 2 == 0:
			print(k//2)
		else:
			print(k//2 + 1)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
# N, M = [int(i) for i in input().split()]
# a = set(input().split())
# a = list(map(lambda x: int(x)//2, a))
# c = 1
# for n in a:
#     c *= n
# print(c)
# print(M//c - M//(c*2))

from fractions import gcd
# from math import gcd

N, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
lcm = a[0]
for n in a:
    lcm = (lcm*n)//gcd(lcm,n)
lcm //= 2
print(M//lcm - M//(lcm*2))

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions as f
from functools import reduce

n,m=map(int,input().split())
a=np.array(list(map(int,input().split())))
a=a//2
def lcm(x,y):
    return (x*y)//f.gcd(x,y)
def lcm_list(num):
    return reduce(lcm,num,1)
l=lcm_list(a)
ans=m//l

#奇数を取り除く
if ans%2==0:
    ans//=2
else:
    ans=ans//2+1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
sk = a[0]

for i in range(1, N):
    sk = sk * a[i] // gcd(sk, a[i])

x = M // (sk//2)
print(math.ceil(x / 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y):
    return (x*y) // gcd(x, y)
def gcds(X):
    return reduce(gcd, X)
def lcms(X):
    return reduce(lcm, X, 1)

N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

print(round(M / lcms(X)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=[int(x) for x in input().split()]

from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
p=1
for a in A:
  p=lcm(p,a)

print(M//p+1)

Submission status: Wrong Answer

Solution code:
from math import ceil
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
m = min(A)
A = [a for a in A]


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


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


while len(A) > 1:
    a, b = A.pop(), A.pop()
    A.append(lcm(a, b))

X = A[0] // 2
print(ceil((M // X) / 2) - int(m // 2 == X))

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(map(lambda x: int(x)//2 ,input().split()))
    # print(A)
    from fractions import gcd
    g = A[0]
    for i in A[1:]:
        g = gcd(g,i)

    lcm = 1
    for i in set(A):
        lcm *= i
    lcm //= g
    # print(lcm)
    print((M-lcm) // (lcm*2) +1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import bisect
import fractions
N ,M = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))

temp = []

# max_div = 0
# for a in As:
#     temp = a
#     hoge = 0
#     while temp % 2 == 0:
#         temp //= 2
#         hoge += 1
#     max_div = max(max_div,hoge)

# print(max_div )
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
flag = 0
temp = 1
for a in As:
    flag += (a//2) % 2
    temp = lcm(temp,a)

if flag == 0 or flag == N:
    print(math.ceil(M / temp))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import math

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)

flag4 = False
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
g = a[0]
for i in range(n):
	g = lcm(g, a[i])
if g % 4 == 0:
	flag4 = True
while g % 2 == 0:
	g //= 2
rb = m // g
if flag4:
	if rb % 4 == 0:
		print(3 * rb // 4)
	else:
		print(3 * rb // 4 + rb % 4)
else:
	if rb % 2 == 0:
		print(rb // 2)
	else:
		print(rb // 2 + 1)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
for num in a:
  b.append(num//2)
c=set(b)
import fractions
ans=b[0]
flag=True

for item in c:
  if item%2==0:
    print(0)
    flag=False
    break

if flag:
  for item in c:
    ans=ans*item // fractions.gcd(ans,item)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import fractions
from functools import reduce
from math import ceil
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

def lcm_list(numbers):
    return reduce(lcm, numbers)
N, M = map(int, input().split())
A = list(map(int, input().split()))
# for i in range(N):
#     A[i] = (A[i] + 0.5) * 10
G = gcd_list(A)
L = lcm_list(A)
l = L // G
# print(G, L)
# ans = (M // l) // 2
# print(ans if ans == 0 else ans + 1)
print(ceil(M / L * 2)//2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 1
for i in set(A):
    tmp = tmp *(i//2)
ans = M//tmp
ans = ((ans+1) //2)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions
import sys
n, m = map(int,input().split())
a = np.array(list(map(int, input().split())))
b = a//2

ans = b[0]
for i in range(1, n):
    ans = ans * b[i] // fractions.gcd(ans, b[i])
if ans%2 == 0:
    print(0)
    sys.exit()
print(m//(ans*2) +1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import fractions
N, M = map(int, input().split())
A = tuple(map(int, input().split()))

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

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

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


Ahalf = [a//2 for a in A]
lcmA = lcm_list(Ahalf)
#print(A)
#print(lcmA)
if lcmA % 2 == 0:
  print(0)
else:
  n = int(M / lcmA + 1) // 2
  print(n)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, input().split())
A = list(set([i for i in map(int, sys.stdin.readline().split())]))

if len(A) > 1:
  a, b = A[0], A[1]
  while b > 0:
    a, b = b, a%b
  
  if len(A) > 2:
    for b in A[2:]:
      while b > 0:
        a, b = b, a%b
        
else:
  a = A[0]
    
prod = 1
for _a in A:
  prod *= _a
  
CM = prod // a
SCM = CM // 2

if SCM > M:
  print(0)
else:
  print(1 + (M - SCM) // CM)

Submission status: Wrong Answer

Solution code:
import fractions
import math
from functools import reduce
n, m = map(int, input().split())
a = list(map(int, input().split()))

LCA = reduce(lambda x, y: (x*y)//fractions.gcd(x, y), a)
print(math.ceil((m//(LCA//2))/2))

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)

x = A[0]
for i in range(1, N):
  x = lcm(x, A[i])
  if x // 2 > M:
    print(0)
    exit()
#print(x)

if x // 2 <= M:
  if x // 2 in A:
    if x * 3 // 2 <= M:
      print((M - x * 3 // 2) // x + 1)
    else:
      print(0)
  else:
    print((M - x // 2) // x + 1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import fractions 
import functools

n,m = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

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

def lcm(numbers):
    return functools.reduce(lcm_base, numbers, 1)

l = lcm(A)
if l//2 > m: print(0)
else:
    tmp = m//l
    if tmp + l//2 <= m: print(m//l + 1)
    else: print(m//l)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from math import ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()

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

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

start = 0
a_max = a[-1]
while a_max * (start + 0.5) <= m:
    flag = True
    for i in range(len(a)-1):
        num = (a_max * (start + 0.5) / a[i]) - 0.5
        if num.is_integer():
            continue
        else:
            flag = False
            break
    if flag:
        break
    else:
        start += 1

if a_max * (start + 0.5) > m:
    print(0)
    exit()

ans = 0
base_num = int(a_max * (start + 0.5))

d = reduce(lcm, a)
ans = int(1 + ((m - base_num) // d))
print(base_num, d)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
from math import ceil

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

def lcm(nums):
    return reduce(lcm_b,nums,1)

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

l = lcm(A)

print(ceil((M*2 // l)/2))

Submission status: Wrong Answer

Solution code:
def p_d():
    from fractions import gcd
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, input().split())

    lcm = A[0]
    for i in range(1, n):
        lcm = lcm * A[i] // gcd(lcm, A[i])
    print((m // lcm + 1) // 2 if lcm & 1 == 1 else 0)
    
p_d()

Submission status: Wrong Answer

Solution code:
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x



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



ans = lcm(A)

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,M = map(int,input().split())
A = list(map(int,input().split()))
lcm = A[0]
ki = 0; gu = 0
k4 = 0; g4 = 0
if (A[0]//2)%2 == 1:
    ki = 1
else:
    gu = 1
    if A[0]%8 == 4:
        k4 = 1
    else:
        g4 = 1

for i in range(1,N):
    if (A[i]//2)%2 == 1:
        ki = 1
    else:
        gu = 1
        if A[i]%8 == 4:
            k4 = 1
        else:
            g4 = 1
    if ki*gu == 1:
        print(0)
        exit()
    if k4*g4 == 1:
        print(0)
        exit()
    lcm = (lcm*A[i]) // gcd(lcm,A[i])
    if lcm > 2*M:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

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

def calc(a,b):
    count_two_a = 0
    count_two_b = 0
    while(a%2==0):
        a //= 2
        count_two_a += 1
    while(b%2==0):
        b //= 2
        count_two_b += 1
    if count_two_a != count_two_b:
        return 0

    return pow(2,count_two_a) * a * b // GCM(a,b)





def main():
    N,M = LI()
    A = LI()

    tmp = A[0]

    for i in range(1,N):
        tmp = calc(tmp,A[i])
    if tmp==0:
        print(0)
        return

    ans = M//tmp + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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


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

b = lcmm(A)//2
if b > m:
    print(0)
else:
    print(-(-(m//b)//2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(li): return reduce(lcm, li, 1)

N, M = MAP()
A = LIST()

l = lcm_list(A)

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ans//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
a = list(set(map(int,input().split())))
flag = 0
x = 1
for i in range(len(a)):
  a[i] = a[i] / 2
  if a[i] % 2 == 0:
    flag = 1
    print(0)
    break
  x = (x * a[i]) // gcd(x, a[i])
if flag == 0:
  print(int((M // x + 1) // 2))

Submission status: Wrong Answer

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

ans=0
for i in range(M):
    x = 0
    for j in range(N):
        if i % A[j] == A[j]//2:
            x = x
        else:
            x = x + 1
    if x == 0:
        ans = ans + 1
    else:
        ans = ans
        
print(ans)

Submission status: Wrong Answer

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

flag=1
import fractions
a[0]=a[0]//2
k=a[0]
for j in range(N-1):
  i=j+1
  a[i]=a[i]//2
  b=fractions.gcd(k,a[i])
  k=(a[i]*k)//b
  if k>M:
    flag=0
    break
if flag==1:
  l=M//k
  if l%2==0:
    print(l//2)
  else:
    print(l//2+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
kouho=[]
for i in A:
    j=1
    while i*(j+0.5)<=M:
        kouho.append([i*(j+0.5)])
        j+=1    
#print(kouho)
count = 0
for k in kouho:
    if kouho.count(k) == N:
        count += 1
print(count//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,M = map(int,input().split())
A = list(map(int,input().split()))
lcm = A[0]
ki = 0; gu = 0
k4 = 0; g4 = 0
if (A[0]//2)%2 == 1:
    ki = 1
else:
    gu = 1
    if A[0]%8 == 4:
        k4 = 1
    else:
        g4 = 1

for i in range(1,N):
    if (A[i]//2)%2 == 1:
        ki = 1
    else:
        gu = 1
        if A[0]%8 == 4:
            k4 = 1
        else:
            g4 = 1
    if ki*gu == 1:
        print(0)
        exit()
    if k4*g4 == 1:
        print(0)
        exit()
    lcm = (lcm*A[i]) // gcd(lcm,A[i])
    if lcm > 2*M:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

a = list(set(a))


for i in range(1, 31):
    flag1 = False
    flag2 = False
    tmp = 2 ** i
    for j in a:
        if j % tmp == 0:
            flag1 = True
        else:
            flag2 = True
    if flag1 and flag2:
        print(0)
        exit()


candidate = 1
for i in a:
    candidate = candidate * i
    if candidate > M:
        print(0)
        exit()
tmp = M // (candidate * 2) + 1
if (tmp + 0.5) * candidate > M:
    tmp -= 1

print(tmp)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

ans = alist[0]

for i in range(1, len(alist)):
    ans = ans * alist[i] // gcd(ans, alist[i])

if M - ans >= 0:
    ans = (M-ans)//(2*ans) + 1
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
cnt = 0
for e in a:
    e //= 2
    lcm *= e // gcd(lcm, e)
    if lcm > m: break
    cnt += e & 1

if cnt in {0, n}:
    res = (1 + m // lcm) // 2
else:
    res = 0
print(res)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,M = map(int,input().split())
A = list(map(int,input().split()))
lcm = A[0]
ki = 0; gu = 0
k4 = 0; g4 = 0
if (A[0]//2)%2 == 1:
    ki = 1
else:
    gu = 1
    if A[0]%8 == 4:
        k4 = 1
    else:
        g4 = 1

for i in range(1,N):
    if (A[i]//2)%2 == 1:
        ki = 1
    else:
        gu = 1
        if A[0]%4 == 4:
            k4 = 1
        else:
            g4 = 1
    if ki*gu == 1:
        print(0)
        exit()
    if k4*g4 == 1:
        print(0)
        exit()
    lcm = (lcm*A[i]) // gcd(lcm,A[i])
    if lcm > 2*M:
        print(0)
        exit()

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