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:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

n,m = LI()
a = LI()
b = [i//2 for i in a]
for i in range(n):
    if b[i] % 2 == 0:
        print(0)
        quit()
if n == 1:
    lb = b[0]
else:
    lb = lcm(b[0],b[1])

for i in range(2,n):
    lb = lcm(lb,b[i])

if lb % 2 == 0:
    print(0)
    quit()

if lb > m:
    print(0)
    quit()

ans = m//lb//2 + (m // lb) %2
print(ans)

Submission status: Wrong Answer

Solution code:
a = input().split()
c = input().split()
A = 0
for i in range(int(a[1])//2):
  d = 0
  for j in range(int(a[0])):
    if (i*2)%int(c[j]) != 0:
      d += 1
  if d == 0:
    A += 1
print(A-1)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    a = tuple(map(int, input().split()))

    for i, j in enumerate(a):
        if i == 0:
            ls = set([k for k in range(j // 2, M, j)])
        else:
            ls &= set([k for k in range(j // 2, M, j)])
    print(len(ls))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy

def lcm(x, y):
    if x % y == 0 or y % x == 0:
        return max(x, y)
    return x * y // gcd(x, y)
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def twos(x):
    m = 16
    ret = 0
    while True:
        if x % (1 << m) == 0:
            x = x >> m
            ret += m
        if m == 0:
            break
        m = m >> 1
    return ret

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

# check
p = twos(a[0])
for x in a:
    if twos(x) != p:
        print(0)
        exit()

a = a // (2 ** p)
l = a[0]
for x in a[1:]:
    l = lcm(l, x)

l *= (1 << (p - 1))

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([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 sys
input = sys.stdin.readline

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

def lcm(a, b):
    return a*b//gcd(a, b)
    
N, M = map(int, input().split())
a = list(map(int, input().split()))
L = 1

for ai in a:
    L = lcm(L, ai//2)

L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

print(M//L-M//L2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
from functools import reduce
alist = list(map(int,input().split(' ')))
alist = [i // 2  for i in alist]



def lcm(a, b):
    if a > b:
        greater = a
    else:
        greater = b

    while True:
        if greater % a == 0 and greater % b == 0:
            lcm = greater
            break
        greater += 1

    return lcm

def get_lcm_for(your_list):
    return reduce(lambda x, y: lcm(x, y), your_list)

lcmr = get_lcm_for(alist)


temp_res = m // lcmr

if (temp_res%2 == 1):
    temp_res += 1

result = temp_res //2


print(result)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]    
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
flag = False
b = lcm(a)
while flag == False:
    for i in range(N):
        if (b // A[i]) % 2 == 1:
            flag = True
    if flag == False:
        b += b
if M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)

A=a[0]

def lcm(X,Y):
    if X%2==1 or Y%2==1:
        print(0)
        exit()
    x=X
    y=Y
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y
    
for i in range(1,N):
    A=lcm(A,a[i])
M-=A//2
if A%4==0:
    print(0)
else:
    print(M//A+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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


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


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


def lcmm(l):
    return reduce(lcm, l)


x = lcmm(a)
print(x)

i = m / x
ans1 = -(-m // x)  # 切り上げ
ans2 = m // x  # 切り捨て

if i >= ans2 + 0.5:
    print(ans1)
else:
    print(ans2)

Submission status: Wrong Answer

Solution code:
import fractions
N,M = map(int,input().split())
A = list(map(int,input().split()))
A2 = []
for i in A:
    A2.append(i//2)
if N == 1:
    lcm = A2[0]
else:
    lcm = (A2[0] * A2[1]) // fractions.gcd(A2[0],A2[1])
    for i in range(2,N):
        lcm = (lcm * A2[i]) // fractions.gcd(lcm,A2[i])
        if lcm > M :
            break
#print(lcm)

if  M < lcm :
    ans = 0
else:
    ans = (M - lcm) // (2 * lcm) + 1
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)

lcms = 1
plus = 1
for x in xs:
    lcms = lcm(lcms,x)
    plus = lcm(plus, x//2)

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

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

div_count = 0
while True:
    all_odd = True
    for i in range(len(a)):
        a[i]//=2
        if a[i]%2==0:
            all_odd = False
        if a[i]==0:
            print(0)
            sys.exit()
    if all_odd is True:
        break
    else:
        div_count+=1

_min=a[0]
for i in range(1, n):
    _min = _min * a[i] // fractions.gcd(_min, a[i])

if div_count>0:
    _min*=2*div_count
print(m//_min-(m//_min)//2)

Submission status: Wrong Answer

Solution code:
import fractions

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

#n, m = 10, 1000000000
#a = [(i+1)*2*316 for i in range(n)]

for i in range(n):
  a[i]//=2

gd = a[0]

for i in range(1,n):
  gd = fractions.gcd(gd, a[i])
  if (gd==1):
    break

sm = 1

for i in range(n):
  a[i] //= gd

for i in range(n):
  sm *= a[i]
  if (sm > m):
    print(0)
    exit(0)

m //= sm
m -= 1
m //= 2

print(m+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

lcma=lcm(*a)
print((m + lcma//2)//lcma)

Submission status: Wrong Answer

Solution code:
import fractions

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

ans = List[0]
for i in range(1, N):
    ans = ans * List[i] // fractions.gcd(ans, List[i])

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

Submission status: Wrong Answer

Solution code:

from fractions import gcd

def lcm(a, b):
    """
    aとbの最小公倍数を計算します。
    """
    return a * b // gcd(a, b)


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

v = A[0] // 2
for i in range(1, N):
    v = lcm(v, A[i] // 2)
print((M // v + 1) // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m, *a = map(int, open(0).read().split())
lcm = 1
f=0
for x in a:
	x //= 2
	if x%2:
		f+=1
	else:
		f-=1
	lcm = lcm * x // gcd(lcm, x)
if not f%n==0:
	print(0)
elif f==n:
	print(m // (2 * lcm) + (m % (2 * lcm) >= lcm))
else:
	print(m // (2 * lcm))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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


def calcLCM(lst):
    ans = lst.pop()
    for val in lst:
        ans = ans * val // gcd(ans, val)
    return ans


ans = 0
sp = -1
for X in range(1, M+1):
    flg = False
    mitasu = []
    for ak in set(A):
        p = X/ak - 0.5
        if p.is_integer() and p > 0:
            flg = True
        else:
            flg = False
            break
    
    if flg:
        ans += 1
        sp = X
        break

if sp == -1:
    print(0)
else:
    ans = ans + M // calcLCM(set(A))
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

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

if any([(a // 2 - 1) % 2 != 0 for a in A]):
    print(0)
else:
    l = lcm(*[a // 2 for a in A])
    ans = m // (2*l)
    if m % (2*l) >= l:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
from functools import reduce
#import math
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)

def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """
    a=lcm_list(A)
    a=a//2
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break


    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from math import gcd
import sys

input = sys.stdin.readline

N, M = [int(i) for i in input().split()]
a = map(int, input().split())
lcm = 1
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 fractions
n,m=map(int,input().split())
a=list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
import math
def gcd(a, b):
     while b:
          a, b = b, a % b
     return a

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

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

co=1
endflag=0
kai=0
for num,i in enumerate(A):
    while True:
        if i>2**co:
            co+=1
        elif i==2**co:
            if num==len(A)-1:
                kai=1
            break
        else:
            endflag=1
            break
    if endflag==1:
        break
    

num=A[0]//2
for i in range(1,len(A)):
    num=lcm(num,A[i]//2)

if kai==1:
    print(0)
else:
    print(math.ceil(m//num/2))
#if num*2==max(A):
#    print(0)
#else:

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) > 2:
  a, b = A[0], A[1]
  prod = a * b
  while b > 0:
    a, b = b, a%b
  
  if len(A) > 3:
    for b in A[2:]:
      prod *= b
      while b > 0:
        a, b = b, a%b
  
  CM = prod // a
  SCM = CM // 2    
  
else:
  CM = A[0]
  SCM = CM // 2

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

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) ,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//2) // (lcm) +1 if M >= lcm//2 else 0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
A=list(map(int, input().split()))
import fractions
ans = A[0]
for i in range(1, N):
    ans = ans * A[i] // fractions.gcd(ans, A[i])
ans = ans // 2
print(int(M/ans + 1)//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


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


def I(): return int(sys.stdin.readline())


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)]


# A
def A():
    K, X = LI()
    if K * 500 >= X:
        print("Yes")
    else:
        print("No")
    return


# B
def B():
    n = I()
    s = S()
    cnt = 0
    for i in range(n - 2):
        if s[i] == "A":
            if s[i + 1] == "B" and s[i + 2] == "C":
                cnt += 1
    print(cnt)
    return


# C
def C():
    n = I()
    p = LI()
    q = LI()
    a_cnt = [1] * n
    b_cnt = [1] * n
    a = 0
    b = 0
    for i in range(1, n + 1):
        num = 1
        for j in range(1, n + 1 - i):
            num *= j
        a += sum(a_cnt[:p[i - 1]]) * num
        b += sum(b_cnt[:q[i - 1]]) * num
        a_cnt[p[i - 1] - 1] = 0
        b_cnt[q[i - 1] - 1] = 0
    print(abs(a - b))
    return


# D
def D():
    def GCD(a, b):
        if (b == 0):
            return a
        else:
            return GCD(b, a % b)

    n, m = LI()
    a = list(int(x) // 2 for x in sys.stdin.readline().split())
    for i in a:
        if i % 2 == 0:
            print(0)
            return
    b = a[0]
    for i in range(1, n):
        b = b * a[i] // GCD(b, a[i])
    if b > m:
        print(0)
    else:
        print((m - b) // (b * 2) + 1)
    return


# E
def E():
    return


# F
def F():
    return


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

Submission status: Wrong Answer

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

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

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

n, m = map(int, stdin.readline().rstrip().split())
arg = np.array(list(map(int, stdin.readline().rstrip().split())))
arg = arg // 2
lcm = lcm_list(arg)
if lcm > m:
    print(0)
else:
    tmp = m // lcm
    if tmp % 2 == 0:
        tmp -= 1
    print((tmp+1)//2)

Submission status: Wrong Answer

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


A=a[0]

def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y
    
for i in range(1,N):
    A=lcm(A,a[i])
M-=A//2
if A%4==0:
    print(0)
else:
    print(M//A+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
x=lcm_list(A)
print(-(-M//2//x))

Submission status: Wrong Answer

Solution code:
import fractions as fr
n,m=map(int,input().split())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
  ans=ans*a[i]//fr.gcd(ans,a[i])
print(int(m//ans)+1)

Submission status: Wrong Answer

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

import fractions
ans = a[0] // 2
for i in range(1, N):
    ans = ans * (a[i] // 2) // fractions.gcd(ans, a[i]//2)

    if M < ans:
        ans = 0
        break

if ans == 0:
    print(0)
elif ans < max(a):  
    print((M - ans) // (2*ans))
else:
    print((M - ans) // (2*ans) + 1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,M = map(int, input().split())
A =  set(map(int, input().split()))

total = 1
for a in A:
    total *= a//2
r = range(total,M+1,total)

if total % 2 == 0:
    print(0)
else:
    print(-(-len(r)//2//1))

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 lcm_list(nums):
    return reduce(lcm,nums,1)


n,m=map(int,input().split())
A=list(map(int,input().split()))
A=[i//2 for i in A]
ans=lcm_list(A)
print((m-ans)//(ans*2)+1)

Submission status: Wrong Answer

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


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

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

# for a in A:
    # baisu = lcm(baisu, a)
# print(baisu)

b = baisu // 2
c = m // b + 1
d = c // 2
print(d)

Submission status: Wrong Answer

Solution code:
[N, M] = [int(x) for x in input().split()]
a = list(set([int(x) for x in input().split()]))
count, new_list = 0, []
for x in range(0, len(a)):
    while a[x] * count <= M:
        new_list.append(a[x] * (count+0.5))
        count += 1
    count = 0
print(len(set([x for x in new_list if new_list.count(x) >= 2])))

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]%8==0:
        sA[i]//=8
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 math
N,M = map(int,input().split())
a = list(map(int,input().split()))
a = set(a)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)
A = 1
for i in a:
    A = lcm(A,i)
print(math.ceil(M/A) if M/A >= 1 else 0)

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)

for i in range(N):
  if A[i] % 4 == 0:
    A[i] = A[i] * 3 // 2
  else:
    A[i] //= 2
maxA = max(A)

if maxA <= M:
  print((M - maxA) // x + 1)
else:
  print(0)

Submission status: Wrong Answer

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

import numpy as np
import fractions
A=np.array(A)

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

mm=1
for x in A//2:
    mm=lcm(mm,x)

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

print(ans)

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=list(map(int,input().split()))

L=1
g=1
for i in range(n):
    L=lcm(L,a[i])
    g=lcm(g,a[i]//2)

ans=(m+g)//L
print(ans)

Submission status: Wrong Answer

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

N ,M = map(int, input().split())
A = list(set(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)

lcm = lcm_list(A)
least_lcm = lcm // 2
print(max(floor( (M - least_lcm) // lcm + 1), 0))

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
import fractions

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [int(int(i)/2) for i in input().split()]
    a = set(a)

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

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

    lcmnum=lcm_list(a)
    count = math.ceil((m//lcmnum)/2)

    print(count)

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]
  prod = a * b
  while b > 0:
    a, b = b, a%b
  
  if len(A) > 2:
    for b in A[2:]:
      prod *= b
      while b > 0:
        a, b = b, a%b
  
  CM = prod // a
  SCM = CM // 2    
  
else:
  CM = A[0]
  SCM = CM // 2

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

Submission status: Wrong Answer

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

def func(a, m):
    return m / a - 1 / 2


tmp = 0

for i in range(1, m // 3):
    count = True
    for j in range(n):
        if not func(a[j], i).is_integer():
            count = False

    if count:
        tmp = i
        break

if tmp == 0:
    print(0)

else:
    print(math.ceil(math.floor(m / tmp) / 2))

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 = list(set(A))
    d = reduce(gcd, A)
    e = A[0] // d
    for a in A[1:]:
        e *= a // d
    e *= 2
    ans = 0
    if M - e//2 > 0:
        ans = (M-e//2) // e
    if e // 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:
import fractions
import math
n, m = map(int, input().split())
a = set(map(int, input().split()))
lcm = 1
for ai in a:
  lcm = (lcm * ai) // fractions.gcd(lcm, ai)
print(round(m / lcm))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int,input().split())
A = list(map(int,input().split()))
hA = list(map(lambda x:x//2,A))
def lcm_of_list(nums):
    lcm = nums[0]
    for i in range(1,len(nums)):
        lcm = (lcm * nums[i])//gcd(lcm,nums[i])
    return lcm

ans = M //lcm_of_list(hA)
#print(lcm_of_list(hA))
if ans !=0:
    ans = ans//2+1
print(ans)

Submission status: Wrong Answer

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

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

def gcd(a, b):
    if (a, b) in gcd_d:
        return gcd_d[(a, b)]
    if b == 0:
        return a
    gcd_d[(a, b)] = gcd(b, a % b)
    return gcd_d[(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:
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)

m1 = False
m2 = False
for e in A:
    if (e//2)%2 == 0:
        m1 = True
    else:
        m2 = True
    if m1 and m2:
        print(0)
        exit()

s = lcm_list(A)
x = s//2
if x > M:
    print(0)
else:
    print((M-x)//s+1)

Submission status: Wrong Answer

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


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = 1
    mi = float("inf")
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            mi = min(mi, a)
            ans = (ans * (a // 2)) // fractions.gcd(ans, a // 2)

    if mi == ans:
        print(0)
        exit()

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



    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

x = 0
p = 0
a = True
result = 0
while m >= x:
  x = aList[0]*(p+0.5)
  for i in range(1,len(aList)):
#    print("x",x)
    f = x/aList[i]-0.5
#    print("aList[i]",f)
    if not(0 <= f and f.is_integer()):
      a = False
      break
  if a == True:
    result += 1
  else:
    a = True

  p += 1
  #print("result",result)

print(result)

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//2)

if flag == 0 or flag == N:
    print(M // temp - (M//(temp * 2))  )
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
flag = True
for a in AA:
    if a % 2 == 0:
        flag = False

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)
def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
if flag:
    l = 1
    for i in range(len(AA)):
        l = lcm(l, AA[i])

    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Submission status: Wrong Answer

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

a = set(sorted(a, reverse=True))

# print(a)

import functools

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

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

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

_c = [x//2 for x in a]
_lcm = lcm(_c)
# print(_lcm)
if _lcm > m:
    print(0)
else:
    print(m//(_lcm*2) - _c[0]//(_lcm*2)+1)

Submission status: Wrong Answer

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

gcd = 1
for i in A:
    gcd = gcd * i//fractions.gcd(gcd,i)

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

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

def lcmlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = lcm(a,l[i])
    return a

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [A[i]//2 for i in range(N)]
X = lcmlist(B)

#print(Aup)
#print(B)
#print(X)

p = M//X
#print(p)
if p%2 == 0:
    ans = p//2
else:
    ans = p//2+1

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

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

if any([(a // 2 - 1) % 2 != 0 for a in A]):
    print(0)
else:
    l = lcm(*[a // 2 for a in A])
    print(m // (2*l) + 1)

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 = lcm(plus, x//2)

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
def GCM(a, b):
  a, b = max(a,b), min(a, b)
  r = a % b
  if r == 0:
    return b
  else:
    return GCM(b, r)

def LCD(a, b):
  g = GCM(a, b)
  return (a//g)*b

N, M = map(int, input().split())
A = list(map(int, input().split()))
X_2 = 1
for a in A:
  X_2 = LCD(X_2, a)
X = X_2//2
print(M//X-M//X_2)