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 math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
a = iln()

l = a[0]
for i in range(1, N):
    l = lcm(l, a[i])
print(M//(l//2) - M//l)

Submission status: Wrong Answer

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

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

n, m = map(int, input().split())
ar = [int(x) for x in input().split()]

L = ar[0] // 2
for i in range(1, n):
    L = LCM(L, int(ar[i] // 2))

x = m / L
print(int((x + 1) // 2))

Submission status: Wrong Answer

Solution code:
def examA():
    K, X = LI()
    if K*500>=X:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    N = I()
    S = SI()
    ans = 0
    for i in range(N-2):
        if S[i:i+3]=="ABC":
            ans +=1
    print(ans)
    return

def examC():
    N = I()
    P = LI()
    Q = LI()
    Cp = [i for i in itertools.permutations(P,N)]; Cp.sort()
    Cq = [i for i in itertools.permutations(Q, N)]; Cq.sort()
#    print(Cp)
#    print(Cq)
    for k,i in enumerate(Cp):
        flag = True
        for j in range(N):
            if P[j]!=i[j]:
                flag = False
                break
        if flag:
            a = k
            break
    for k,i in enumerate(Cq):
        flag = True
        for j in range(N):
            if Q[j]!=i[j]:
                flag = False
                break
        if flag:
            b = k
            break
    ans = abs(a-b)
    print(ans)
    return

def gcd(x,y):
    if y==0:
        return x
    while(y!=0):
        x, y = y,x%y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examD():
    N, M = LI()
    A = LI()
    flag4 = False; flag2 = False
    for a in A:
        if a%4==0:
            flag4 = True
        else:
            flag2 = True
        if flag4 and flag2:
            print(0)
            return
    cur = A[0]
    for i in range(1,N):
        cur = lcm(cur,A[i])
        if cur>2*M:
            print(0)
            return
    ans = 1 + (M-cur//2)//cur
    print(ans)
    return

def examE():
    N = I()
    C = LI()


    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

Submission status: Wrong Answer

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

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

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


bl = [i//2 for i in al]

ans = 1
for b in bl:
   ans = lcm(ans, b)

def ceil(a, b):
   return a // b + (a % b > 0)

print(ceil(m // ans, 2))

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

a = list(map(int,input().split()))
a2 = [int(i//2) for i in a]
flag = False
eo = a2[0]%2
for i in range(1,N):
    if a2[i]%2 != eo:
        flag = True
if flag:
    print(0)
else:
    if N == 1:
        div = M//a2[0]
        print((div+1)//2)
    else:
        gcda = a2[0]*a2[1]//gcd(a2[0],a2[1])
        for i in range(2,N):
            gcda = gcda*a2[i]//gcd(gcda,a2[i])
        div = M//gcda
        print((div+1)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

a = sorted(list(set(a)))

owa = 0
saiko = a[0]//2
che = (a[0]//2)%2
for i in range(1,len(a)):
    if (a[i]//2)%2 != che:
        owa = 1
        break
    t1 = a[i]//2
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe

if owa == 1:
    print(0)
else:
    if (M//saiko)%2 == 0:
        print((M//saiko)//2 )
    else:
        print(((M//saiko)+1)//2)

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

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

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]
for i in range(1,n):
  L=lcm(L,a[i])
  if L>=10**9+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
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(n):
  B.append(A[i]//2)
b=1
for i in range(n):
  b=b*B[i]//fractions.gcd(b,B[i])
if b>m:
  print(0)
else:
  print(1+(m-b)//(2*b))

Submission status: Wrong Answer

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

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
print(M//A+1)

Submission status: Wrong Answer

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

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


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

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

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

x_l = lcm_list([int(a_i / 2)for a_i in a])
if x_l % 2 == 0:
  print(0)
else:
  print(math.ceil((m // x_l) / 2))

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_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i]) 
    return ans

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


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

div = multi_lcm(a)
ans = 0
if m - div // 2 >= 0:
    ans += 1
m = m - div // 2 
ans += m // div
if  m - div // 2 < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

def lcm(a, b):
    g = gcd(a, b)
    g_a = a // g
    g_b = b // g
    return g_a * g_b * g

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



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

num = 1
for i in range(n):
    num = lcm(num, b[i])

if num % 2 == 0:
    print(0)
    exit()
if num > m:
    print(0)
    exit()

p = m // num
if p % 2 == 0:
    print(p//2)
else:
    print((p+1)//2)

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X = MI()
    A=LI()
    lcm = 1
    odd = False
    even = False
    for a in A:
        a//=2
        if a&1:
            odd=True
        else:
            even = True
        if odd and even:
            print(0)
            return
        if lcm > X:
            print(0)
            return
        lcm = lcm//gcd(a,lcm)*a
    print(ceil(X//lcm/2))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def main():
    if sum([a%2 for a in A])>0:
        print(0)
        return
    n = sum([1 for a in A if a%4==0])
    if not (n==0 or n==N):
        print(0)
        return
    B = [a//2 for a in A]
    lcm = B[0]
    for b in B[1:]:
        g = gcd(lcm,b)
        lcm = lcm*b//g
    ans = M//lcm
    if ans%2:
        ans = ans//2 + 1
    else:
        ans = ans//2
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
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 = [int(x)//2 for x in input().split()]

g = A[0]
for i in range(1, N):
    g = lcm(g, A[i])

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
a = iln()

l = a[0]
for i in range(1, N):
    l = lcm(l, a[i])
print(l)
print(M//(l//2) - M//l)

Submission status: Wrong Answer

Solution code:
import math
import sys

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

def f(n):
    return int(n)//2
n,m=map(int,input().split())
a=list(map(f,input().split()))
for i in range(n):
    if a[i]%2==0: print(0),sys.exit()

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


ans=m//(tmp*2)

if m%(tmp*2)>=tmp: ans+=1
print(ans)

Submission status: Wrong Answer

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

n,m=map(int,input().split())
a=set([int(i) for i in input().split()])
a=list(a)
w=a[0]
n=len(a)
for i in range(n):
    w=lcm(a[i],w)
print(m//w if w else 0)

Submission status: Wrong Answer

Solution code:
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()))
B = [a//2 for a in A]

base = B[0]

is_break = False
for b in B:
  if base % b == 0:
    continue
  
  new_base = lcm(base, b)
  if (new_base // base) % 2 == 0:
    is_break = True
    break

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


print(ans)

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]
for item in c:
  ans=ans*item // fractions.gcd(ans,item)
  
cnt=0
print(((M//ans)+1)//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()))

num=A[0]//2
for i in range(1,len(A)):
    num=lcm(num,A[i]//2)
#print(num)
print(math.ceil(m//num/2))

Submission status: Wrong Answer

Solution code:
import fractions
import math

N, M = list(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])

x = 2 * M // ans
y = math.ceil(x/2)
print(int(y))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

l = 1
for ai in a:
    l *= ai // gcd(l, ai)
    if 0.5 * l > M:
        ans = 0
        break
else:
    ans = (M + l // 2) // l

print(ans)

Submission status: Wrong Answer

Solution code:
#D
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
for i in range(N):
    if A[i] not in B:
        B.append(A[i])
    else:
        N-=1

def GCD(x,y):
    x,y = max(x,y),min(x,y)
    if y == 0:
        return x
    else:
        return GCD(y,x%y)
    
g = B[0]
for i in range(N-1):
    g = GCD(B[i+1],g)
    
bai = g
for i in range(N):
    bai*=B[i]//g
    
han = bai//2
print(math.ceil((M//han)/2))

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 = A[0] // 2
    for a in A:
        ans = (ans * a // 2) // fractions.gcd(ans, a // 2)

    if ans > M:
        print(0)
        exit()
    print(-((-M // ans) // 2))


    
    
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
from fractions import gcd
from functools import reduce
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template

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

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

def main():
    n, m = mi()
    a = lmi()
    a = list(map(lambda x: x // 2, a))
    now = 1
    for i in range(n):
        now = lcm_base(now, a[i])
        if(now >= 2 * m):
            print(0)
            exit()
    la = now
    x = m // la
    print((x + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

res = 1
for i in range(N):
    res = lcm(res,a[i])
    if res >= (10**12):
        print(0)
        exit()
#print(res)
if res%2==1 or res == 0:
    print(0)
    exit()
if M < res//2:
    print(0)
    exit()
k = (2*M//res + 1)//2
print(k)

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_list(numbers):
    return reduce(lcm_base, numbers, 1)


N, M = map(int, input().split())
Bs = list(map(lambda x: int(x) // 2, input().split()))
X = lcm_list(Bs)
if X % 2 == 0:
    print(0)
else:
    print((M // X + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

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

def main():
    n,m=MI()
    aa=LI()
    l=1
    for a in aa:
        if a%4==0:
            print(0)
            exit()
        l=lcm(l,a//2)
    print((m//l+1)//2)

main()

Submission status: Wrong Answer

Solution code:
import fractions
import math

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


n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i]) // fractions.gcd(lcm_all, a[i])
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

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

hana=[]

for i in a:
  hana.append(i//2)

from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

mini=lcm_list(hana)

ans=1+((m-mini)//(2*mini))

print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---
 
def scm(a, b):
  _gcd = gcd(a, b)
  return a * b // _gcd

def main():
  n,m=LI()
  l=LI()

  m*=2

  k=l[0]
  for x in l[1:]:
    k=scm(k,x)

  _a=m//k
  if _a%2==0:
    return _a//2
  return -(-_a//2)

# main()
print(main())

Submission status: Wrong Answer

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

def lcm(values):
    ans = values[0]
    for i in range(1, len(values)):
        ans = ans * values[i] // gcd(ans, values[i])
    return ans

min_value = lcm(A)
print(M * 2 // min_value // 2 + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

# bの最小公倍数を求める
lcm = b[0]
for i in range(1, N):
    lcm = lcm * b[i] // gcd(lcm, b[i])

# 1, 2, ..., M の中で lcm * 奇数 の形で表せるものの個数が答え
if (M // lcm) % 2 == 0:
    print(M // lcm // 2)
else:
    print(M // lcm // 2 + 1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
  A[i] //= 2
L = A[0]
if N != 1:
  L = A[0]
  for i in range(1, N):
    a, b = L, A[i]
    while b != 0:
      a, b = b, a % b
    L //= a
    B = A[i] // a
    L = L * a * B
fa = M // L
ev = M // (2 * L)
print(fa - ev)

Submission status: Wrong Answer

Solution code:
n, m = [int(v) for v in input().split()]
alist = [int(v) for v in input().split()]
hlist = [a // 2 for a in alist]

log = {}
def gcd(m, n):
    if m < n:
        m, n = n, m
    def _gcd(p, q):
        if (p, q) in log:
            return log[p, q]
        t = p % q
        res = q if t == 0 else _gcd(q, t)
        log[p, q] = res
        return res
    return _gcd(m, n)

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

common = 1
for h in hlist:
    common = lcm(common, h)

cntwice = m // common
print(cntwice // 2 + cntwice % 2)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

def lcm(a, b):
	return a * b // fractions.gcd(a, b)
tmp = 1
for x in a:
    tmp = lcm(tmp, x//2)
# print(tmp)
ans = (M // tmp + 1) // 2
print(ans)

Submission status: Wrong Answer

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

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

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

y = M//ans
if y%2==1:
    y+=1
print(int(y/2))

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
a=list(map(int,input().split()))
t=1
for i in a:
    t=t*i//fractions.gcd(t,i)
tc=t//2
if tc<=m:
    print((m-tc)//t+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
gh = 0
l = 1
dbl = [0] * N
for i in range(N):
  x = a[i]
  t = 0
  while x % 2 == 0:
    x //= 2
    t += 1
  dbl[i] = t
if max(dbl) != min(dbl):
  print(0)
  exit(0)
t = pow(2, dbl[0])
for x in a:
  gh = gcd(gh, x // t)
s = set()
for i in range(N):
  if a[i] in s: continue
  s.add(a[i])
  l *= a[i] // (t * gh)
  if l > M:
    print(0)
    exit(0)
print(M // l - M // (2 * l))

Submission status: Wrong Answer

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

lcm = functools.reduce(lambda x, y: x // gcd(x, y) * y, A)
print((M - lcm // 2) // lcm + 1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n, m = map(int, readline().split())
a = list(map(int, read().split()))
half_a = [x // 2 for x in a]


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


cnt = m // f_ - m // f
print(cnt)

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 = A[0]
    for a in A:
        ans = (ans * a // 2) // fractions.gcd(ans, a // 2)

    if ans > M:
        print(0)
        exit()
    if M % ans:
        print(M // ans + 1)
    else:
        print(M // ans)


    
    
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def GCD(x,y):
    if y==0:
        return x
    return GCD(y,x%y)


N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = 1
for i in A:
    if i%4 == 0:
        print(0)
        exit()
    ans = (ans*(i//2))//GCD(ans,i)

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

Submission status: Wrong Answer

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

def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

for _ in filter(lambda x:x % 4 == 0,A):
    print(0)
    exit()

su = 1
for a in A:
    a //= 2
    su = su * a // gcd(su,a)

print(M//su - M//(su*2))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
a = inpl()
g = 1
for i in range(n):
    g = g*a[i]//fractions.gcd(g,a[i])
# print(g)
if g%4:
    print((m-g//2)//g+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def examA():
    K, X = LI()
    if K*500>=X:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    N = I()
    S = SI()
    ans = 0
    for i in range(N-2):
        if S[i:i+3]=="ABC":
            ans +=1
    print(ans)
    return

def examC():
    N = I()
    P = LI()
    Q = LI()
    Cp = [i for i in itertools.permutations(P,N)]; Cp.sort()
    Cq = [i for i in itertools.permutations(Q, N)]; Cq.sort()
#    print(Cp)
#    print(Cq)
    for k,i in enumerate(Cp):
        flag = True
        for j in range(N):
            if P[j]!=i[j]:
                flag = False
                break
        if flag:
            a = k
            break
    for k,i in enumerate(Cq):
        flag = True
        for j in range(N):
            if Q[j]!=i[j]:
                flag = False
                break
        if flag:
            b = k
            break
    ans = abs(a-b)
    print(ans)
    return

def gcd(x,y):
    if y==0:
        return x
    while(y!=0):
        x, y = y,x%y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examD():
    N, M = LI()
    A = LI()
    flag4 = False; flag2 = False
    for a in A:
        if a%4==0:
            flag4 = True
        else:
            flag2 = True
        if flag4 and flag2:
            print(0)
            return
    cur = A[0]
    for i in range(1,N):
        cur = lcm(cur,A[i])
        if cur>2*M:
            print(0)
            break
    ans = 1 + (M-cur//2)//cur
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
ans=a[0]
for i in range(1,n):
    ans = ans * a[i] // gcd(ans, a[i])
ans//=2
if ans>m:
    print(0)
else:
    print(m//ans//2+1)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
a = [int(c) for c in input().split()]
b = [c//2 for c in a]
g = reduce(lcm_base, b, 1)
G = reduce(lcm_base, a, 1)
if M<g:
  print(0)
else:
  n = (M-g)//G
  print(n+1)

Submission status: Wrong Answer

Solution code:
import fractions

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


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


M2=2*M

ans=0
if M2>=lcm:
    M2-=lcm
    ans+=1
    ans+=M2//(lcm*2)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)

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


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


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


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

print((2 * M + a - 1) // a // 2)