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,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 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 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 gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

def main():
    N, M = LI()
    A = LI()
    g = 1
    for i in range(N):
        A[i] //= 2
        g = lcm(g, A[i])
    shou = M // g
    if shou % 2 == 1:
        shou -= 1
        ans = shou // 2
        ans += 1
    else:
        ans = shou // 2
    print(ans)


main()

Submission status: Wrong Answer

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

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

fv=A[0]//2
fmod=A[0]

for i in range(1,N):
    sv=A[i]//2
    smod=A[i]

    x,y,gcd=egcd(fmod,smod)
    fv=fv-fmod*x*(fv-sv)//gcd
    fmod=fmod*smod//gcd
    fv=(fv+fmod)%fmod

if M<fv:
    print(0)
    exit(0)

if fv==0:
    print((M-fv)//fmod)
else:
    print((M-fv)//fmod+1)

Submission status: Wrong Answer

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

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

l = A[0]//2
even = l % 2 == 0
for k in range(1, N):
    a = A[k]//2
    if (even and a % 2 != 0) or (not even and a % 2 == 0):
        print(0)
        exit()
    l = lcm(l, a)

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

Submission status: Wrong Answer

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

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

l = A[0]//2
even = l % 2 == 0
for k in range(1, N):
    a = A[k]//2
    if (even and a % 2 != 0) or (not even and a % 2 == 0):
        print(0)
        exit()
    l = lcm(l, a)

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

Submission status: Wrong Answer

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

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

l = A[0]
even = (A[0] // 2) % 2 == 0
for k in range(1, N):
    if (even and (A[k] // 2) % 2 != 0) or (not even and (A[k] // 2) % 2 == 0):
        print(0)
        exit()
    l = lcm(l, A[k])

if l//2 < max(A):
    print((M-(l//2)) // l)
else:
    print((M-(l//2)) // l + 1)

Submission status: Wrong Answer

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

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

l = A[0]
even = (A[0] // 2) % 2 == 0
for k in range(1, N):
    if (even and (A[k] // 2) % 2 != 0) or (not even and (A[k] // 2) % 2 == 0):
        print(0)
        exit()
    l = lcm(l, A[k])

print((M-(l//2)) // l + 1)

Submission status: Wrong Answer

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

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

l = 1
for k in range(N):
    l = lcm(l, A[k])

print((M-(l//2)) // l + 1)

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i)//2 for i in input().split()]

if N == 1:
    print((M//a[0]+1)//2)
    sys.exit()

A = []
s = set()
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    s.add(cur)
    if len(s) >= 2:
        print(0)
        sys.exit()
lcm = lcm_list(A)
print((M//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M//a[0]+1)//2)
    sys.exit()

A = []
b, c = 0, 1
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    b = max(b, cur)
    c = min(c, cur)
if b != c:
    print(0)
    sys.exit()
for x in a:
    A.append(x//(2**b))
lcm = lcm_list(A)
print((M//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
b, c = 0, 1
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    b = max(b, cur)
    c = min(c, cur)
if b != c:
    print(0)
    sys.exit()
for x in a:
    A.append(x//(2**b))
lcm = lcm_list(A)
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
b, c = 0, 1
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    b = max(b, cur)
    c = min(c, cur)
    A.append(x//2)
if b != c:
    print(0)
    sys.exit()
lcm = lcm_list(A)
if lcm in a:
    print(0)
    sys.exit()
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
b, c = 0, 1
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    b = max(b, cur)
    c = min(c, cur)
    A.append(x//2)
if b != c:
    print(0)
    sys.exit()
lcm = lcm_list(A)
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
for x in a:
    if x//2%2 == 0:
        print(0)
        sys.exit()
    A.append(x//2)
lcm = lcm_list(A)
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
for x in a:
    A.append(x//2)
lcm = lcm_list(A)
if lcm in a:
    print(0)
    sys.exit()
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
for x in a:
    A.append(x//2)
lcm = lcm_list(A)
if lcm in A:
    print(0)
    sys.exit()
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
from functools import reduce
import sys

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, input().split())
a = [int(i) for i in input().split()]

if N == 1:
    print((M-a[0]//2)//a[0])
    sys.exit()

A = []
for x in a:
    A.append(x//2)
lcm = lcm_list(A)
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
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, input().split())
a = [int(i) for i in input().split()]
A = []
for x in a:
    A.append(x//2)
lcm = lcm_list(A)
print(ceil(M//lcm/2))

Submission status: Wrong Answer

Solution code:
import sys
t=0
def hanbun(n):
  if n%2==0:
    return n//2
  else:
    return 0
def waru(n):
  t=0
  if n%2==0:
    t+=1
    return waru(n//2)
  else:
    return t
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def k(a,b):
  return (a*b)//gcd(a,b)
N,M=map(int,input().split())
L=list(map(int,input().split()))
L=list(set(map(hanbun,L)))
if 0 in L:
  print(0)
  sys.exit()
S=list(set(map(waru,L)))
if len(S)>1:
  print(0)
  sys.exit()
s=1
for i in range(len(L)):
  s=k(s,L[i])
if (M//s)%2==0:
  print((M//s)//2)
else:
  print(((M//s)//2)+1)

Submission status: Wrong Answer

Solution code:
import sys
t=0
def hanbun(n):
  if n%2==0:
    return n//2
  else:
    return 0
def waru(n):
  t=0
  if n%2==0:
    t+=1
    return waru(n//2)
  else:
    return t
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def k(a,b):
  return (a*b)//gcd(a,b)
N,M=map(int,input().split())
L=list(map(int,input().split()))
L=list(set(map(hanbun,L)))
if 0 in L:
  print(0)
  sys.exit()
S=list(set(map(waru,L)))
if len(S)>1:
  print(0)
  sys.exit()
s=1
for i in range(len(L)):
  s=k(s,L[i])
  if s%2==0:
    print(0)
    sys.exit()
if (M//s)%2==0:
  print((M//s)//2)
else:
  print(((M//s)//2)+1)

Submission status: Wrong Answer

Solution code:
import sys
def hanbun(n):
  if n%2==0:
    return n//2
  else:
    return 0
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def k(a,b):
  return a*b//gcd(a,b)
N,M=map(int,input().split())
L=list(map(int,input().split()))
L=list(set(map(hanbun,L)))
if 0 in L:
  print(0)
  sys.exit()
s=1
for i in range(len(L)):
  s=k(s,L[i])
  if s%2==0:
    print(0)
    sys.exit()
if (M//s)%2==0:
  print((M//s)//2)
else:
  print(((M//s)//2)+1)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from math import gcd

def main():
    n, m, *a = map(int, read().split())
    if n == 1:
        r = m // (a[0]//2) + 1
        print(int(r))
        sys.exit()
    d = [0] * n
    for i, ae in enumerate(a):
        t1 = 0
        while ae > 0:
            if ae % 2 == 0:
                t1 += 1
                ae /= 2
            else:
                break
        d[i] = t1
    d_c = [de == d[0] for de in d]
    if not all(d_c):
        print(0)
        sys.exit()

    div = 2**d[0]
    a2 = [ae // div for ae in a]
    m /= div
    g = (a2[0] * a2[1]) // gcd(a2[0], a2[1])
    for i1 in range(1, n):
        g = (g * a2[i1]) // gcd(g, a2[i1])
        if g > m:
            print(0)
            sys.exit()

    r = m // g + 1
    print(int(r))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from math import gcd

def main():
    n, m, *a = map(int, read().split())
    a.sort()
    a2 = [i // 2 for i in a]
    if n == 1:
        r = m // a[0] + 1
        print(r)
        sys.exit()
    g = (a2[0] * a2[1]) // gcd(a2[0], a2[1])
    for i1 in range(1, n):
        g = (g * a2[i1]) // gcd(g, a2[i1])
    r = 0
    while g <= m:
        r += g <= m
        g *= a2[0]

    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def hanbun(n):
  return n//2
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def k(a,b):
  return a*b//gcd(a,b)
N,M=map(int,input().split())
L=list(map(int,input().split()))
L=list(set(map(hanbun,L)))
s=1
for i in range(len(L)):
  s=k(s,L[i])
  if s%2==0:
    print(0)
    sys.exit()
if (M//s)%2==0:
  print((M//s)//2)
else:
  print(((M//s)//2)+1)

Submission status: Wrong Answer

Solution code:
from math import gcd, ceil
import sys
N,M = map(int, input().split())
a = list(map(int, input().split()))
tmp = 1
for i in range(N):
    tmp = tmp * (a[i]//2) // gcd(tmp, (a[i]//2))
for i in range(N):
    if tmp // a[i] % 2 == 0:
        print(0)
        sys.exit()
print(ceil((M // tmp) / 2))

Submission status: Wrong Answer

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

import math
import sys

tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        sys.exit()
print(ceil((M // tmp) / 2))

Submission status: Wrong Answer

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

import math
import sys

tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        sys.exit()
print((M//tmp+1) // 2)

Submission status: Wrong Answer

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

import math
tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm
    
allo=1
for i in range(N):
    allo&=(lcm//a[i])%2
if allo:
    print((M//lcm+1)//2)
else:
    print(0)

Submission status: Wrong Answer

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

import math
tmp = 1
for i in range(N):
    lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2))
    tmp = lcm

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

Submission status: Wrong Answer

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

import math
tmp = 1
for i in range(N):
    lcm = tmp*a[i]//math.gcd(tmp,a[i])
    tmp = lcm
tmp //= 2

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

Submission status: Wrong Answer

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

import math
tmp = 1
for i in range(N):
    lcm = tmp*a[i]//math.gcd(tmp,a[i])
    tmp = lcm
tmp //= 2

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

Submission status: Wrong Answer

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

import math
tmp = 1
for i in range(N):
    lcm = tmp*a[i]//math.gcd(tmp,a[i])
    tmp = lcm
tmp //= 2

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x//2,a))
lcm = np.lcm.reduce(a)
ans = m//lcm//2

if lcm*(ans+1) <= m:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int,input().split())
a = list(map(int,input().split()))
lcm = np.lcm.reduce(a)
b = list(str(m/lcm))
ans = m//lcm

for i in range(len(b)):
    if b[i] == '.':
        if int(b[i+1]) >= 5:
            ans += 1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m = map(int,input().split())
a = list(map(int,input().split()))
lcm = lcm_list(a)
b = list(str(m/lcm))
ans = m//lcm

for i in range(len(b)):
    if b[i] == '.':
        if int(b[i+1]) >= 5:
            ans += 1
        break

print(ans)

Submission status: Wrong Answer

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

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

def cnt(a):
  res = 0
  while(a and a % 2 == 0):
    a //= 2
    res += 1
  return res

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

l = 1
c = cnt(A[0])
print(c)
for a in A:
  if cnt(a) != c or c == 0:
    print(0)
    exit()
  else:
    l = lcm(l, a // 2)
print(l)
d = m // l
print((d + 1) // 2)

Submission status: Wrong Answer

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

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

def cnt(a):
  res = 0
  while(a and a % 2 == 0):
    a //= 2
    res += 1
  return res

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

l = 1
c = cnt(A[0])
for a in A:
  if cnt(a) != c or c == 1:
    print(0)
    exit()
  else:
    l = lcm(l, a)
d = m // l
print((d + 1) // 2)

Submission status: Wrong Answer

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

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

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

l = 1
for a in A:
  if a % 2 != 0 or (a // 2) % 2 == 0:
    print(0)
    exit()
  else:
    l = lcm(l, a // 2)

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

Submission status: Wrong Answer

Solution code:
# ABC150D

import sys
input=sys.stdin.readline
from math import gcd,ceil

def main():
    N,M=map(int,input().split())
    A=list(map(lambda x: int(x)//2,input().split()))
    lcm=A[0]
    for i in range(1,N):
        lcm=lcm*A[i]//gcd(lcm,A[i])
    print(ceil(int(M//lcm)/2))
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC150D

import sys
input=sys.stdin.readline
from math import gcd,ceil

def main():
    N,M=map(int,input().split())
    A=list(map(lambda x: int(x)//2,input().split()))
    lcm=A[0]
    for i in range(1,N):
        lcm=lcm*A[i]//gcd(lcm,A[i])
    print(ceil((M//lcm)/2))
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
temp = 1
for i in range(n):
    temp = temp * a[i] // math.gcd(temp, a[i])
temp2 = temp // 2
print(m // temp2 - m // temp)

Submission status: Wrong Answer

Solution code:
from math import gcd
def lcm(a,b):return (a*b)//(gcd(a,b))

def f(x):
    cnt=0
    while(x%2==0):
        cnt+=1
        x=x//2
    return cnt

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

t=f(a[0])
for i in a:
    if(f(i)!=t):
        print(0)
        exit()
    i=i//(2**t)
m=m//(2**t)
l=1
for i in a:
    l=lcm(l,i)
    if(l>m):
        print(0)
        exit()
m=m//l
print((m+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 != 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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


if n == 1:
    cnt = (m-al[0]//2)//al[0] + 1
    print(cnt)
    exit()



a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 != 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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


if n == 1:
    cnt = (m-al[0]//2)//al[0]
    print(cnt)
    exit()



a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 != 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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

a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

if n==1:
    curr_lcm*=2
    lcm_cnt = (m-curr_lcm//2)//curr_lcm
else:
    lcm_cnt = m//curr_lcm
    lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 != 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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

a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

# if n==1:
#     curr_lcm*=2
#     lcm_cnt = (m-curr_lcm//2)//curr_lcm
# else:

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


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

a4_flag = False
a2_flag = False
for a in al:
    if a%4 == 0:
        a4_flag = True
    else:
        a2_flag = True

if a4_flag and a2_flag:
    print(0)
    exit()


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

if n==1:
    curr_lcm*=2
    lcm_cnt = (m-curr_lcm//2)//curr_lcm
else:
    lcm_cnt = m//curr_lcm
    lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import gcd

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


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

a4_flag = False
a2_flag = False
for a in al:
    if a%4 == 0:
        a4_flag = True
    else:
        a2_flag = True

if a4_flag and a2_flag:
    print(0)
    exit()


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

print(lcm_cnt)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

Bs = [A//2 for A in As]

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

L = reduce(lcm, Bs)
#print('L:', L)

if L%2:
    ans = M//L - M//(2*L)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

l = int(lcm_list(A))
for i in range(N):
    if (A[i]/l) % 2 == 0 or A[i] == l:
        print(0)
        exit()
ans = math.floor(M//(l/2))
print(math.ceil(ans/2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

l = int(lcm_list(A))
for i in range(N):
    if (A[i]//l) % 2 == 0:
        print(0)
        exit()
ans = math.floor(M//(l//2))
print(math.ceil(ans//2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

l = int(lcm_list(A))
for i in range(N):
    if (A[i]/l) % 2 == 0:
        print(0)
        exit()
ans = math.floor(M/(l/2))
print(math.ceil(ans/2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

l = int(lcm_list(A))
for i in range(N):
    if (A[i]/l) % 2 == 0:
        print(0)
        exit()
print(math.floor((2*M-l)/(2*l))+1)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

l = lcm_list(A)
print(math.floor((2*M-l)/(2*l))+1)

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

n, m = map(int,input().split())
a = list(map(int,input().split()))
a = [x // 2 for x in a]#リストの要素すべてを2で割る

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

def lcm_list(numbers): #最小公倍数を求める
    return reduce(lcm_base, numbers, 1)

def num_dev2(x):
    return bin(x)[::-1].find("1") #２で割り切れる回数を確認

lcm = lcm_list(a)
q = m #lcm,mは最小公倍数で何回割れるか

count = 0
dev2 = num_dev2(a[0])
for i in range(1,n):
    if dev2 != num_dev2(a[i]):#リストのすべての要素の２で割れる回数は等しいか
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう

half_multiple_num = 1
for num in nums:
    half_multiple_num = num * half_multiple_num
if half_multiple_num > M:
    print(0)
else:
    # print(half_multiple_num)
    # 割り切れない時
    if M % half_multiple_num != 0:
        # +1した値が2の倍数の時
        if ((M // half_multiple_num) + 1) % 2 == 0:
            print(int(((M // half_multiple_num) + 1) / 2))
        else:
            print(int(((M // half_multiple_num) + 1) // 2))
    # 割り切れる時
    else:
        if (M / half_multiple_num) % 2 == 0:
            print(int((M / half_multiple_num) // 2) + 1)
        else:
            print(int((M / half_multiple_num) // 2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう

half_multiple_num = 1
for num in nums:
    half_multiple_num = num * half_multiple_num
if half_multiple_num > M:
    print(0)
else:
    # print(half_multiple_num)
    if M % half_multiple_num == 0:
        print(int((M // half_multiple_num) / 2))
    else:
        print(int(((M // half_multiple_num) + 1) / 2))

Submission status: Wrong Answer

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

if lcm(Ali)%2 == 1:
  print(0)
else:
  a = lcm(Ali)
  b = a//2
  print((M-b)//a+1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l=list(set(l))
n=len(l)
ll=[]
for i in l:
    ll.append(int(i/2))


newl=[]
for i in ll:
    j=i
    count=0
    while j%2!=0:
        j//=2
        count+=1
        newl.append(count)
import collections
newl=collections.Counter(newl)
if len(newl)!=1:
    print(0)
     
else:
    from fractions import gcd
    num=ll[0]
    flag=True
    for i in ll:
        if num<=m:
            num=int(i*num/gcd(i,num))
        else:
            flag=False
            break
    if flag==False:
        print(0)
    else:
        k=m%(num*2)
        if k>=num:
            print(int(m//(num*2)+1))
        else:
            print(int(m//(num*2)))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l=list(set(l))
n=len(l)
ll=[]
for i in l:
    ll.append(int(i/2))

flag=True
for i in ll:
    if i%2==0:
        flag=False
        break
if flag==False:
    print(0)
     
else:
    from fractions import gcd
    num=ll[0]
    flag=True
    for i in ll:
        if num<=m:
            num=int(i*num/gcd(i,num))
        else:
            flag=False
            break
    if flag==False:
        print(0)
    else:
        k=m%(num*2)
        if k>=num:
            print(int(m//(num*2)+1))
        else:
            print(int(m//(num*2)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

numdic = {}

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

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

lcmnum = lcm_list(alist)

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

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

l = lcm(*(int(x) // 2 for x in input().split()))

print(m // l - m // (2*l))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

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

l = lcm(*map(int, input().split()))

print(m // (l//2) - m // l)