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


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


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = list(map(lambda x: int(x)//2, input().split()))

    a = list(set(a))
    # print(a)

    lcm = a[0]
    for i in a:
        lcm = calc_lcm(lcm, i)

    # print(lcm)

    # print(m, lcm)
    print(math.ceil((m//lcm)/2))

Submission status: Wrong Answer

Solution code:
import math
import fractions


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


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = list(map(lambda x: int(x)//2, input().split()))

    a = list(set(a))
    # print(a)

    lcm = a[0]
    for i in a:
        lcm = calc_lcm(lcm, i)

    # print(lcm)

    print((m//lcm)//2 + (lcm % 2))

Submission status: Wrong Answer

Solution code:
# import math
import fractions


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


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = list(map(lambda x: int(x)//2, input().split()))

    a = list(set(a))
    # print(a)

    lcm = a[0]
    for i in a:
        lcm = calc_lcm(lcm, i)

    # print(lcm)

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

Submission status: Wrong Answer

Solution code:
from fractions import*
n,m,*a=map(int,open(0).read().split())
s=1
for i in a:
  i//=2
  s*=i//gcd(s,i)
print(max(0,0--(m//s)//2))

Submission status: Wrong Answer

Solution code:
from fractions import*
n,m,*a=map(int,open(0).read().split())
s=1
for i in a:
  i//=2
  s*=i//gcd(s,i)
print(0--(m//s)//2)

Submission status: Wrong Answer

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

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

A_h = [a//2 for a in A]
l = lcm_list(A_h)

if l % 2 == 0:
  print(0)
else:
  print(int((m / l + 1) // 2))

Submission status: Wrong Answer

Solution code:
import fractions
N,M= map(int,input().split())
A=[int(x) for x in input().split()]
B = []
ans = 0
for i in range(N):
    B.append(A[i]//2)
l = B[0]
for i in range(1,N):
    l = l * B[i] // fractions.gcd(l,B[i])
quo = M //l
if quo %2 == 1:
    print((quo-1)//2+1)
else:
    print(quo//2)

Submission status: Wrong Answer

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

k = 0
while True:
    if a[0] % 2:
        break
    a[0] = a[0] // 2
    k += 1
base = 2 ** k

f = 0
for i in range(1,n):
    if a[i] % base:
        f = 1
        break
    a[i] = a[i] // base
    if a[i] % 2 == 0:
        f = 1
        break
if f:
    print(0)
else:
    LCM = a[0]
    for ai in a:
        LCM = LCM * ai // fractions.gcd(LCM, ai)
    LCM *= base // 2
    print(LCM)
    print(((m // LCM) + 1) // 2)

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    g = 2
    s = set()
    for c in a:
        t = fractions.gcd(g, c)
        g *= c // t
        i = 0
        while c % 2 == 0:
            c //= 2
        s.add(i)

    if len(s) > 1:
        return 0

    g //= 2
    t = (m // g + 1) // 2

    return t


print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    g = 2
    for c in a:
        t = fractions.gcd(g, c)
        g *= c // t

    g //= 2
    t = (m // g + 1) // 2

    return t


print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    g = 1
    for c in a:
        t = fractions.gcd(g, c)
        g *= c // t

    g //= 2
    t = m // g
    if t < 2:
        return t

    return (m - g) // g // 2 + 1


print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    g = 1
    for c in a:
        t = fractions.gcd(g, c)
        g *= c // t

    g //= 2

    return (m // g + 1) // 2


print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    g = 1
    for c in a:
        t = fractions.gcd(g, c)
        g *= c // t
        if g > m*2:
            return 0

    g //= 2

    return (m // g + 1) // 2


print(main())

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

#####2で奇数回割り切れる場合のみのflag
flag=0

a=[]
a_2=power2(A[0])

for i in range(len(A)): ###len(A) ###### A[0]をa=[]にappendする
  if power2(A[i])==a_2:
    a.append(A[i]*0.5)
  else:
    flag=1

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)  
  
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

if flag==0:
  lcm=lcm_list(a)
  amari=NM[1]/lcm #50までは15,30,45の3つ
  amari=(amari+1)//2 #3つのうち奇数を切り上げ
  ########roundは偶数への丸め(0.5は1になる):https://note.nkmk.me/python-round-decimal-quantize/
  ########四捨五入するならdecimalモジュールのquantize('.01')
  #Decimal(i).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)
  print(int(amari)) 
else:
  print(0)
#print(A,a,flag,amari)

Submission status: Wrong Answer

Solution code:
import math
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 = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = int(lcm_list(a) // 2)

tmp = 0
bol = 0
while a[0] % 2 == 0:
        a[0] = a[0] // 2
        tmp += 1
cnt = 0
for num in a:
    while num % 2 == 0:
        num = num // 2
        cnt += 1
    if cnt != tmp:
        bol = 1

if lc > m: print(0)
elif bol == 1: print(0)
else: print(int(((m / lc) + 1) // 2))

Submission status: Wrong Answer

Solution code:
import math
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 = (int(x) for x in input().split())
a = list(map(int, input().split()))

tmp = a[0] // 2
bol = 0
for i in a:
    if tmp != i//2:
        bol = 1

lc = int(lcm_list(a) // 2)

if lc > m: print(0)
elif bol == 1: print(0)
else: print(int(((m / lc) + 1) // 2))

Submission status: Wrong Answer

Solution code:
import math
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 = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = int(lcm_list(a) // 2)
if lc > m: print(0)
else: print(int(((m / lc) + 1) // 2))

Submission status: Wrong Answer

Solution code:
import math
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 = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = int(lcm_list(a) // 2)
if lc > m: print(0)
else: print(int((m / lc) // 2 + 1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

#####2で奇数回割り切れる場合のみのflag
flag=0

a=[]
a_2=power2(A[0])

for i in range(len(A)):###len(A) ###### A[0]をa=[]にappendする
  if power2(A[i])==a_2:
    a.append(A[i]*0.5)
  else:
    flag=1

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

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

if flag==0:
  lcm=lcm_list(a)
  amari=NM[1]/lcm #50までは15,30,45の3つ
  print(int(round(amari/2))) #3つうち奇数を切り上げ
  
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

flag=0
#####2で奇数回割り切れる場合のみのflag

a=[]
a_2=power2(A[0])

for i in range(1,len(A)):###len(A)
  if power2(A[i])==a_2:
    a.append(A[i]*0.5)
  else:
    flag=1

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
if flag==0:
  lcm=lcm_list(a)
  amari=NM[1]/lcm #50までは15,30,45の3つ
  print(int(round(amari/2))) #3つうち奇数を切り上げ
  
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

a=[]
a_2=power2(A[0])

for i in range(len(A)):###len(A)
  if power2(A[i])==a_2:
    a.append(A[i]*0.5)

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)

amari=NM[1]/lcm #50までは15,30,45の3つ

print(int(round(amari/2))) #3つうち奇数を切り上げ

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math
import numpy as np

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

a = np.array(a)
tmp = (a/2).astype(np.int)

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

cnt = int(math.log2(a[0]))
for i in range(1, len(a)):
    if int(math.log2(a[0])) != cnt:
        print(0)
        break
else:
    ans = max((m-lcm) // (lcm*2) + 1, 0)
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math
import numpy as np

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

a = np.array(a)
tmp = (a/2).astype(np.int)

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

cnt = int(math.log2(a[0]))
for i in range(1, len(a)):
    if int(math.log2(a[0])) != cnt:
        print(0)
        break
else:
    ans = (m+lcm) // (lcm*2)
    print(ans)

Submission status: Wrong Answer

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

import numpy as np

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

a = np.array(a)
tmp = (a/2).astype(np.int)

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

ans = (m+lcm) // (lcm*2)
print(ans)

Submission status: Wrong Answer

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

import numpy as np

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

a = np.array(a)
tmp = (a/2).astype(np.int)

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

m -= lcm
ans = m // (lcm*2)
ans += 1
print(ans)

Submission status: Wrong Answer

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

import numpy as np

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

a = np.array(a)
tmp = (a/2).astype(np.int)

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

ans = m // (lcm*2)
if m%(lcm*2) >= lcm:
    ans += 1
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()))
for a in A:
    if a%2:
        print(0)
        exit()
_lcm=A[0]
for i in range(1,N):
    A[0]=lcm(A[0],A[i])
#print(A[0])
print((M-(A[0]-A[0]//2-A[0]))//A[0])

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

x2 = 0
sample_a = a[0]
while sample_a %2 == 0:
    sample_a = sample_a // 2
    x2 += 1

X_exist = True
for i in range(N):
    if a[i] % 2**x2 != 0:
        X_exist = False
        break

if X_exist == True:
    T = a[0]//2
    for i in range(1,N):
        T = a[i]*T//2 // fractions.gcd(a[i]//2,T)
        if T > M:
            T = 0
            break
    if T == 0:
        print(0)
    else:
        if M//T %2 == 0:
            print((M//T)//2)
        else:
            print((M//T)//2 + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

x2 = 0
sample_a = a[0]
while sample_a %2 == 0:
    sample_a = sample_a // 2
    x2 += 1

X_exist = True
for i in range(N):
    if a[i] % 2**x2 != 0:
        X_exist = False
        break

if X_exist == True:
    T = a[0]//2
    for i in range(1,N):
        T = a[i]*a[i-1]//4 // fractions.gcd(a[i]//2,a[i-1]//2)
        if T > M:
            T = 0
            break
    if T == 0:
        print(0)
    else:
        if M//T %2 == 0:
            print((M//T)//2)
        else:
            print((M//T)//2 + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from fractions import gcd
from functools import reduce

def fnGCD(lNum):
  return reduce(gcd, lNum)

def fnLCM0(iX, iY):
  return (iX * iY) // gcd(iX, iY)

def fnLCM(lNum, iM):
  iRet = lNum[0]
  for i in lNum[1:]:
    iRet = (iRet * i) // gcd(iRet, i)
    if iRet //2 > iM:
      return 2*iM + 10
  return iRet

def fnSolv():
  iNum, iM = map(int , input().split() )
  lA = list(map(int , input().split() ))
  iLCM = fnLCM(lA, iM)
  #print(iLCM)
  if iLCM//2 > iM:
    print(0)
  else:
    print((iM - iLCM//2) // iLCM + 1)

if __name__ == '__main__':
  fnSolv()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from fractions import gcd
from functools import reduce

def fnGCD(lNum):
  return reduce(gcd, lNum)

def fnLCM0(iX, iY):
  return (iX * iY) // gcd(iX, iY)

def fnLCM(lNum, iM):
  iRet = lNum[0]
  for i in lNum[1:]:
    iRet = (iRet * i) // gcd(iRet, i)
    if iRet //2 > iM:
      return 2*iM + 1
  return iRet

def fnSolv():
  iNum, iM = map(int , input().split() )
  lA = list(map(int , input().split() ))
  iLCM = fnLCM(lA, iM)
  #print(iLCM)
  if iLCM//2 > iM:
    print(0)
  else:
    print((iM - iLCM//2) // iLCM + 1)

if __name__ == '__main__':
  fnSolv()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from fractions import gcd
from functools import reduce

def fnGCD(lNum):
  return reduce(gcd, lNum)

def fnLCM0(iX, iY):
    return (iX * iY) // gcd(iX, iY)

def fnLCM(lNum):
    return reduce(fnLCM0, lNum, 1)

def fnSolv():
  iNum, iM = map(int , input().split() )
  lA = list(map(int , input().split() ))
  iLCM = fnLCM(lA)
  #print(iLCM)
  if iLCM//2 > iM:
    print(0)
  else:
    print((iM - iLCM//2) // iLCM + 1)

if __name__ == '__main__':
  fnSolv()

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

def lcd(a,b):
    return a*b//fractions.gcd(a,b)
2
def semi_common(a,b):
    tmp=abs(a//2-b//2)
    if a==b:
        return a
    elif (a%(abs(a-b)))==0:
    	return 0
    elif tmp%(a%(abs(a-b)))==0:
        i=0
        while True:
            if (a//2+a*i-b//2)%b==0:
                return a//2+a*i
                break
            i+=1
    else:
        return 0

n,m=map(int,input().split())
a=list(map(int,input().split()))
tmp=a[0]
for i in range(len(a)-1):
    tmp=semi_common(tmp,a[i+1])
    if tmp==0:
        break

k=reduce(lcd,a)

if tmp==0:
    print(0)
elif m>tmp:
    print((m-tmp)//k+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def bk(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
N,M = map(int,input().split())
A = list(map(int,input().split()))
k = bk(A[0])
flag = 0
for i in range(1,N):
    if bk(A[i])!=k:
        flag==1
        break
if flag==1:
    cnt = 0
else:
    b = A[0]
    for i in range(1,N):
        b1 = gcd(b,A[i])
        b = b1*(b//b1)*(A[i]//b1)
    c = b//2
    cnt = M//c-M//b
print(cnt)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def bk(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
N,M = map(int,input().split())
A = list(map(int,input().split()))
k = bk(A[0])
flag = 0
for i in range(1,N):
    if bk(A[i])!=k:
        flag==1
        break
if flag==1:
    cnt = 0
else:
    b = A[0]
    for i in range(1,N):
        b1 = gcd(b,A[i])
        b = b1*(b//b1)*(A[i]//b1)
    c = b//2
    if c<=M:
        cnt = (M-c)//b+1
    else:
        cnt = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def bk(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
N,M = map(int,input().split())
A = list(map(int,input().split()))
k = bk(A[0])
flag = 0
for i in range(1,N):
    if bk(A[i])!=k:
        flag==1
        break
if flag==1:
    cnt = 0
else:
    b = A[0]
    for i in range(1,N):
        b1 = gcd(b,A[i])
        b = b1*(b//b1)*(A[i]//b1)
    c = b//2
    cnt = (M-c)//b+1
print(cnt)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def bk(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
N = len(A)
k = bk(A[0])
flag = 0
for i in range(1,N):
    if bk(A[i])!=k:
        flag==1
        break
if flag==1:
    cnt = 0
else:
    a = A[0]
    for i in range(1,N):
        a = gcd(a,A[i])
    b = A[0]
    for i in range(1,N):
        b1 = gcd(b,A[i])
        b = b1*(b//b1)*(A[i]//b1)
    c = b//2
    cnt = (M-c)//b+1
print(cnt)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def bk(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
N = len(A)
k = bk(A[0])
flag = 0
for i in range(1,N):
    if bk(A[i])!=k:
        flag==1
        break
if flag==1:
    cnt = 0
else:
    a = A[0]
    for i in range(1,N):
        a = gcd(a,A[i])
    b = a
    for i in range(N):
        b *= A[i]//a
    c = b//2
    cnt = (M-c)//b+1
print(cnt)

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

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

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

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

tmp = lcm(*A) // 2
# print (tmp)
ans = M // tmp

ans = (ans + 1) // 2

print (ans)

Submission status: Wrong Answer

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


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

# 全Aが2で割り切れる数が等しいか確認
cnt = 1
while A[0]%(1<<cnt) == 0 :
    cnt += 1
for i in range(1,N):
    if (A[i]%(1<<cnt) == 0) or (A[i]%(1<<(cnt-1)) != 0):
        print(0)
        sys.exit()

A.append(1)
a = A[0]
b = A[1]
lcm = a * b // GCD(a,b)
#print(lcm)
if lcm > M:
    print(0)
    sys.exit()
for i in range(2,N):
    a = lcm
    b = A[i]
    lcm = a * b // GCD(a,b)
    if lcm > M:
        print(0)
        sys.exit()
print( (M+lcm+1) // (lcm*2) )

Submission status: Wrong Answer

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

def num_double(n):
	return int(n/2)

def main():
  N,M=map(int,input().split())
  numList=list(map(int,input().split()))
  numList=list(map(num_double,numList))
  numList=list(set(numList))
  
  count=0
  flag=0
  finFlag=0
  evenCount=0
  
  while flag==0:
    evenCount=0
    for i in range(len(numList)):
      if(numList[i]%2==0):
        evenCount+=1
        M=math.floor(M/2)
    if(evenCount==len(numList)):
      numList=list(map(num_double,numList))
    elif(evenCount==0):
      flag=1
    else:
      flag=1
      finFlag=1
  
  if(finFlag==1):
    print(count)
    sys.exit()
  
  else:
    def lcm_base(x, y):
        return (x * y) // fractions.gcd(x, y)

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

    endFlag=0
    nowMagnification=1
    nowNum=0
    startNum=lcm_list(numList)

    while endFlag==0:
      nowNum=startNum*nowMagnification
      if(1<=nowNum)and(nowNum<=M):
        count+=1
        nowMagnification+=2
        continue
      else:
        endFlag=1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def num_double(n):
	return int(n/2)

def main():
  N,M=map(int,input().split())
  numList=list(map(int,input().split()))
  numList=list(map(num_double,numList))
  numList=list(set(numList))
  
  flag=0
  finFlag=0
  evenCount=0
  
  while flag==0:
    evenCount=0
    for i in range(len(numList)):
      if(numList[i]%2==0):
        evenCount+=1
        M=math.floor(M/2)
    if(evenCount==len(numList)):
      numList=list(map(num_double,numList))
    elif(evenCount==0):
      flag=1
    else:
      flag=1
      finFlag=1
  
  if(finFlag==1):
    print("0")
    sys.exit()
  
  def lcm_base(x, y):
      return (x * y) // fractions.gcd(x, y)

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

  endFlag=0
  count=0
  nowMagnification=1
  nowNum=0
  startNum=lcm_list(numList)

  while endFlag==0:
    nowNum=startNum*nowMagnification
    if(1<=nowNum)and(nowNum<=M):
      count+=1
      nowMagnification+=2
    else:
      endFlag=1

  print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def num_double(n):
	return int(n/2)

def main():
  N,M=map(int,input().split())
  numList=list(map(int,input().split()))
  numList=list(map(num_double,numList))
  numList=list(set(numList))
  
  flag=0
  finFlag=0
  evenCount=0
  
  while flag==0:
    evenCount=0
    for i in range(len(numList)):
      if(numList[i]%2==0):
        evenCount+=1
        M=math.floor(M/2)
    if(evenCount==len(numList)):
      numList=list(map(num_double,numList))
    elif(evenCount==0):
      flag=1
    else:
      flag=1
      finFlag=1
  
  if(finFlag==1):
    print("0")
    sys.exit()
  
  def lcm_base(x, y):
      return (x * y) // fractions.gcd(x, y)

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

  endFlag=0
  count=0
  nowMagnification=1
  nowNum=0
  startNum=lcm_list(numList)

  if():
    count=0
  else:
    while endFlag==0:
      nowNum=startNum*nowMagnification
      if(1<=nowNum)and(nowNum<=M):
        count+=1
        nowMagnification+=2
      else:
        endFlag=1

  print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def num_double(n):
	return int(n/2)

def main():
  N,M=map(int,input().split())
  numList=list(map(int,input().split()))
  numList=list(map(num_double,numList))
  numList=list(set(numList))
  
  flag=0
  finFlag=0
  evenCount=0
  
  while flag==0:
    evenCount=0
    for i in range(len(numList)):
      if(numList[i]%2==0):
        evenCount+=1
    if(evenCount==len(numList)):
      numList=list(map(num_double,numList))
    elif(evenCount==0):
      flag=1
    else:
      flag=1
      finFlag=1
  
  if(finFlag==1):
    print("0")
    sys.exit()
  
  def lcm_base(x, y):
      return (x * y) // fractions.gcd(x, y)

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

  endFlag=0
  count=0
  nowMagnification=1
  nowNum=0
  startNum=lcm_list(numList)

  if():
    count=0
  else:
    while endFlag==0:
      nowNum=startNum*nowMagnification
      if(1<=nowNum)and(nowNum<=M):
        count+=1
        nowMagnification+=2
      else:
        endFlag=1

  print(count)


if __name__ == '__main__':
    main()