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 fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print((m // (ans//2)+1)//2)

Submission status: Wrong Answer

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

def lcm(a,b):
    return a * b // gcd(a,b)
def ls_lcm(A):
    return reduce(lcm ,A)
def ls_gcd(A):
    return reduce (gcd, A)

N, M = map(int, input().split())
A = list(map(int, input().split()))
half = ls_lcm(A) // 2
#print (((M // half) + 1) // 2)
print ((M + half) // (2*half))

Submission status: Wrong Answer

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

def lcm(a,b):
    return a * b // gcd(a,b)
def ls_lcm(A):
    return reduce(lcm ,A)
def ls_gcd(A):
    return reduce (gcd, A)

N, M = map(int, input().split())
A = list(map(int, input().split()))
half = ls_lcm(A) // 2
print (((M // half) + 1) // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def calc_half(n):
    return n//2

def lcm(L):
    ret=1
    for i in range(len(L)):
        ret=(ret*L[i])//gcd(ret,L[i])
    return ret

n,m=map(int,input().split())
A=list(map(int,input().split()))
Auniq=list(set(A))
Ahalf=list(map(calc_half,Auniq))
lcm_ori=lcm(Auniq)
lcm_half=lcm(Ahalf)

if m<lcm_half:
    print("0")
else:
    print(1+(m-lcm_half)//lcm_ori)

Submission status: Wrong Answer

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

from fractions import gcd
from math import ceil

cnt = 1
flg = True
while 1:
    num = 2*cnt
    lis = [1 if x%num==0 else 0 for x in As]
    s = sum(lis)
    if s==N:
        cnt+=1
        continue
    elif s==0:
        break
    else:
        flg = False
        break

if flg:
    lcm = As[0]
    for i in range(1, N):
        a = As[i]
        lcm = a*lcm//gcd(lcm, a)
    
    print(ceil((M//lcm)/2))
else:
    print(0)

Submission status: Wrong Answer

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

from fractions import gcd
from math import ceil

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

print(ceil((M//lcm)/2))

Submission status: Wrong Answer

Solution code:
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, m = map(int, input().split())
    if n==1:
        a=int(input())
        print(-(-(m//a) // 2))

    else:
        A = list(map(int, input().split()))
        B = [0]*n
        for i in range(n):
            B[i] = A[i]//2

        for i in range(n):
            cnt = 0
            val = B[i]
            while val % 2 == 0:
                val //= 2
                cnt += 1
            if i == 0:
                temp = cnt
            else:
                if cnt != temp:
                    ok = False
                    break
                if i == n-1:
                    ok = True

        if ok:
            from functools import reduce
            from fractions import gcd

            def lcm(A, B):
                return A * B // gcd(A, B)

            # リストを引数にとる
            l = reduce(lcm, B)
            print(-(-(m//l) // 2))

        else:
            print(0)


resolve()

Submission status: Wrong Answer

Solution code:
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, m = map(int, input().split())
    if n==1:
        print(0)
    else:
        A = list(map(int, input().split()))
        B = [0]*n
        for i in range(n):
            B[i] = A[i]//2

        for i in range(n):
            cnt = 0
            val = B[i]
            while val % 2 == 0:
                val //= 2
                cnt += 1
            if i == 0:
                temp = cnt
            else:
                if cnt != temp:
                    ok = False
                    break
                if i == n-1:
                    ok = True

        if ok:
            from functools import reduce
            from fractions import gcd

            def lcm(A, B):
                return A * B // gcd(A, B)

            # リストを引数にとる
            l = reduce(lcm, B)
            print(-(-(m//l) // 2))

        else:
            print(0)


resolve()

Submission status: Wrong Answer

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

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

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

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

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

count = f(a[0])

for i in range(n):
    if f(a[i]) != count:
        print(0)
        sys.exit()
    a[i] /= 2**count
m /= 2**count

l = 1
for i in range(n):
    l = lcm(l,a[i])
    if l > m:
        print(0)
        sys.exit()
m /= l

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

Submission status: Wrong Answer

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

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

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

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

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

count = f(a[0])

for i in range(n):
    if f(a[i]) != count:
        print(0)
        sys.exit()
    a[i] /= 2**count
m /= 2**count

l = 1
for i in range(n):
    l = lcm(l,a[i])
    if l > m:
        print(0)
        sys.exit()
tmp = m//l

ans = math.ceil(tmp/2)
print(int(ans))

Submission status: Wrong Answer

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

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

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

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

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

count = f(a[0])

for i in range(n):
    if f(a[i]) != count:
        print(0)
        sys.exit()
    a[i] /= 2**count
m /= 2**count

l = 1
for i in range(n):
    l = lcm(l,a[i])
tmp = m//l

ans = math.ceil(tmp/2)
print(int(ans))

Submission status: Wrong Answer

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

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

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

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

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

count = f(a[0])

for i in range(n):
    if f(a[i]) != count:
        print(0)
        sys.exit()

for i in range(n):
    a[i] /= 2**count
l = 1
for i in range(n):
    l = lcm(l,a[i])
tmp = m//l

ans = math.ceil(tmp/2)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
def mult_crt(b1,m1,b2,m2):
    gcd = xgcd(m1,m2)
    if b1 % gcd[0] != b2 % gcd[0]:
        return False
    else:
        x = b1 + m1*(m2-b1)//gcd[0]*gcd[1]
        m3 = (m1*m2) // fractions.gcd(m1,m2)
        b3 = x % m3
        return b3,m3
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    bm = mult_crt(temp[1],temp[0],a[i]//2,a[i])
    if bm:
        temp[0] = bm[1]
        temp[1] = bm[0]
    else:
        broke = True
        break
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

Submission status: Wrong Answer

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

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

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

flag = False
b = a.copy()
while b[0] > 0:
    for i in range(n):
        b[i] /= 2
for i in range(n):
    if b[i] != 0:flag = True

if flag :print(0)
else:
    l = 1
    for i in range(n):
        l = lcm(l,a[i]//2)
    ans = m//l
    if ans == 0: print(ans)
    else:
        tmp = l*ans
        if tmp%2 == 1 and l%2 == 1:
            ans -= 1
            ans /= 2
            ans += 1
        elif tmp%2 == 1 and l%2 == 0:
            ans /= 2
        elif tmp%2 == 0 and l%2 == 1:
            ans /= 2
        elif tmp%2 == 0 and l%2 == 0:
            ans -= 1
            ans /= 2
        print(int(ans))

Submission status: Wrong Answer

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

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

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

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

ans = m//l
if ans == 0: print(ans)
else:
    tmp = l*ans
    if tmp%2 == 1 and l%2 == 1:
        ans -= 1
        ans /= 2
        ans += 1
    elif tmp%2 == 1 and l%2 == 0:
        ans /= 2
    elif tmp%2 == 0 and l%2 == 1:
        ans /= 2
    elif tmp%2 == 0 and l%2 == 0:
        ans -= 1
        ans /= 2
    print(int(ans))

Submission status: Wrong Answer

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

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

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

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

ans = m//l
tmp = l*ans
if tmp%2 == 1 and l%2 == 1:
    ans -= 1
    ans /= 2
    ans += 1
elif tmp%2 == 1 and l%2 == 0:
    ans /= 2
elif tmp%2 == 0 and l%2 == 1:
    ans /= 2
elif tmp%2 == 0 and l%2 == 0:
    ans -= 1
    ans /= 2
print(int(ans))

Submission status: Wrong Answer

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

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

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

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

ans = m//l
tmp = l*ans
if tmp%2 == 1:
    ans -=1
    ans /= 2
    ans +=1
else:
    ans /= 2
print(int(ans))

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//gcd(a, b)*b

def lcms(l):
    l = a[0]
    for num in a[1:]:
        l = lcm(l, num)
    return l

n, m = map(int, input().split())
a = list(map(int, input().split()))
# a2 = [num//2 for num in a]
acount = [None]*n # aを2で割れる回数
anum = [None]*n # 割ったあとの残り(=奇数)
for i,num in enumerate(a):
    c = 0
    while num%2==0 and num>1:
        num //=2
        c += 1
    acount[i] = c
    anum[i] = num
if all(item==acount[0] for item in acount):
    l = lcms(anum)
    num0 = l * (pow(2, (acount[0]-1)))
    span = num0*2
    if m<num0:
        print(0)
    else:
        print(int((m-num0)//span + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
# a2 = [num//2 for num in a]
acount = [None]*n # aを2で割れる回数
anum = [None]*n # 割ったあとの残り(=奇数)
for i,num in enumerate(a):
    c = 0
    while num%2==0 and num>1:
        num //=2
        c += 1
    acount[i] = c
    anum[i] = num
if all(item==acount[0] for item in acount):
    lcm = anum[0]
    for num in anum[1:]:
        g = fractions.gcd(lcm, num)
        lcm = lcm * num / g
    num0 = lcm * (pow(2, (acount[0]-1)))
    span = num0*2
    if m<num0:
        print(0)
    else:
        print(int((m-num0)//span + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
# a2 = [num//2 for num in a]
acount = [None]*n # aを2で割れる回数
anum = [None]*n # 割ったあとの残り(=奇数)
for i,num in enumerate(a):
    c = 0
    while num%2==0:
        num //=2
        c += 1
    acount[i] = c
    anum[i] = num
if all(item==acount[0] for item in acount):
    cc = {}
    lcm = anum[0]
    for num in anum[1:]:
        g = fractions.gcd(lcm, num)
        lcm = lcm * num / g
    num0 = lcm * (pow(2, (acount[0]-1)))
    span = num0*2
    if m<num0:
        print(0)
    else:
        print(int((m-num0)//span + 1))
else:
    print(0)

Submission status: Wrong Answer

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

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

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

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

for i in range(N):
    t = b[i]
    
    while t%2==0:
        cnt[i] += 1
        t //= 2
    
if cnt!=cnt[0]*N:
    print(0)
    exit()

L = 1

for bi in b:
    L = lcm(L, bi)

if L>M:
    print(0)
else:
    print((M-L)//(2*L)+1)

Submission status: Wrong Answer

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

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

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

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

for i in range(N):
    t = b[i]
    
    while t%2==0:
        cnt[i] += 1
        t //= 2
    
if cnt==cnt[0]*N:
    print(0)
    exit()

L = 1

for bi in b:
    L = lcm(L, bi)

if L>M:
    print(0)
else:
    print((M-L)//(2*L)+1)

Submission status: Wrong Answer

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

lst2 = []
for num in lst:
    a = []
    for i in range(1,M+1):
        x = num // 2 + num*i
        if x < M:
            a.append
        else:
            break
    lst2.append(a)
a = set(lst2[0])
#print(a)
for i in range(len(lst2)):
    a &= set(lst2[i])
    #print(a)
print(len(a))

Submission status: Wrong Answer

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

lst2 = []
for num in lst:
    a = []
    for i in range(1,M+1):
        x = num // 2 + num*i
        if x < M:
            a.append(x)
    lst2.append(a)
a = set(lst2[0])
#print(a)
for i in range(len(lst2)):
    a &= set(lst2[i])
    #print(a)
print(len(a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import fractions
import numpy as np
import math

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

a = np.array(a)//2

gcd_a = a[0]
for i in range(1, len(a)):
    gcd_a = fractions.gcd(gcd_a, a[i])

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


a_ = a//gcd_a
a_ = (a_+1) % 2

if np.any(a_) is True:
    print(0)
else:
    print(math.ceil(m//(lcd_a)/2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import fractions
import numpy as np
import math

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

a = np.array(a)//2

gcd_a = a[0]
for i in range(1, len(a)):
    gcd_a = fractions.gcd(gcd_a, a[i])

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

if lcd_a == 0:
    print(0)
else:
    print(math.ceil(m//(lcd_a)/2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import fractions
import numpy as np
import math

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

a = np.array(a)//2

gcd_a = a[0]
for i in range(1, len(a)):
    gcd_a = fractions.gcd(gcd_a, a[i])


right = np.prod(a//gcd_a)
# print(gcd_a)
# print(right)

if right == 0:
    print(0)
else:
    print(math.ceil(m//(right*gcd_a)/2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import fractions
import numpy as np
import math

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

a = np.array(a)//2

gcd_a = a[0]
for i in range(1, len(a)):
    gcd_a = fractions.gcd(gcd_a, a[i])


right = np.prod(a//gcd_a)
# print(gcd_a)
# print(right)

if right == 0:
    print(0)
else:
    print(math.ceil(m//(right)/2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=[int(i)//2 for i in input().split()]
def lcm(x,y):
  return x*y//gcd(x,y)
l=a[0]
for i in a:
  l=lcm(l,i)
print((m//l+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=[int(i)//2 for i in input().split()]
def lcm(x,y):
  return x*y//gcd(x,y)
l=a[0]
for i in a:
  l=lcm(l,i)
print(m//l//2+(m//l)%2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
a = sorted(list(set(a)))
from fractions import gcd
lc = a[0]
if n != 1:
  for num,i in enumerate(a[1:]):
    if lc == 0:
      break
    lc = lc * i // gcd(lc, i)
    if gcd(lc, i) == min(i,lc):
      for j in a[:num]:
        if (i//j)%2 == 0:
          lc = 0
          break 
if lc == 0:
  print(0)
else:
  print((m+lc//2)//lc)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
a = list(set(a))
from fractions import gcd
lc = a[0]
if n != 1:
  for i in a[1:]:
      lc = lc * i // gcd(lc, i)
      if gcd(lc, i) == min(i,lc) and (max(i,lc)//min(i,lc))%2 == 0:
        lc = 0
        break
if lc == 0:
  print(0)
else:
  print((m+lc//2)//lc)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
a = list(set(a))
from fractions import gcd
lc = a[0]
if n != 1:
  for i in a[1:]:
      lc = lc * i // gcd(lc, i)
      if (gcd(lc, i) == max(i,lc) and (max(i,lc)//min(i,lc))%2 == 0) or lc > 2*m:
        lc = 0
        break
if lc == 0:
  print(0)
else:
  print((m+lc//2)//lc)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
from fractions import gcd
lc = a[0]
if n != 1:
  for i in a[1:]:
      lc = lc * i // gcd(lc, i)
      if (lc != 1 and gcd(lc, i) == max(i,lc)) or lc > 2*m:
        lc = 0
        break
if lc == 0:
  print(0)
else:
  print((m+lc//2)//lc)

Submission status: Wrong Answer

Solution code:
import fractions
n,num=map(int,input().split())
num_set=set(map(lambda x:int(x)//2,input().split()))
for i in num_set:
  if i%2==0:
    print(0)
    break
else:
  num_list=list(num_set)
  lcm=num_list[0]
  for i in range(1,len(num_list)):
    lcm = lcm * num_list[i] // fractions.gcd(lcm, num_list[i])
  print((num-lcm)//(2*lcm)+1)

Submission status: Wrong Answer

Solution code:
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2
def computeGCD(x, y): 
    x,y=min(x,y),max(x,y)
    while x:
        x,y=y%x,x
    return y
for i in range(N-1):
    temp=temp*(A[i+1]//2)//computeGCD(temp,(A[i+1]//2))
cnt=0
while A[0]%2==0:
    cnt+=1
    A[0]//=2
temp1=temp
while temp1%2==0:
    cnt-=1
    temp1//=2

if cnt!=0:
    print(0)
    exit() 
ans=M//temp
ans=ans+1
ans//=2
print(ans)

Submission status: Wrong Answer

Solution code:
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2
def computeGCD(x, y): 
    x,y=min(x,y),max(x,y)
    while x:
        x,y=y%x,x
    return y
for i in range(N-1):
    temp=temp*(A[i+1]//2)//computeGCD(temp,(A[i+1]//2))
 
ans=M//temp
ans=ans+1
ans//=2
print(ans)

Submission status: Wrong Answer

Solution code:
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2
def computeGCD(x, y): 
    x,y=min(x,y),max(x,y)
    while x:
        x,y=y%x,x
    return y
for i in range(N-1):
    temp=temp*(A[i+1]//2)//computeGCD(temp,(A[i+1]//2))
M+=temp 
ans=M*100+1//(2*temp)*100
print(ans)

Submission status: Wrong Answer

Solution code:
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2
def computeGCD(x, y): 
    x,y=min(x,y),max(x,y)
    while x:
        x,y=y%x,x
    return y
for i in range(N-1):
    temp=temp*(A[i+1]//2)//computeGCD(temp,(A[i+1]//2))
M+=temp 
ans=M//(2*temp)
print(ans)

Submission status: Wrong Answer

Solution code:
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2
def computeGCD(x, y): 
    if x > y: 
        small = y 
    else: 
        small = x 
    for i in range(1, small+1): 
        if((x % i == 0) and (y % i == 0)): 
            gcd = i     
    return gcd

for i in range(N-1):
    temp=temp*(A[i+1]//2)//computeGCD(temp,(A[i+1]//2))
M+=temp 
ans=M//(2*temp)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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

#def gcd(*numbers):
#    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

tmp = lcm(*a)
#print(tmp)
ans_tmp = tmp // 2 # 最小公倍数
#print(ans_tmp)

if ans_tmp % 2 == 0:
    print(0)
else:
    ans = (m // ans_tmp) // 2
    if ans * ans_tmp >= m:
        print(int(ans))
    else:
        print(int(ans+1))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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

#def gcd(*numbers):
#    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

tmp = lcm(*a)
#print(tmp)
ans_tmp = tmp // 2 # 最小公倍数
#print(ans_tmp)

ans = (m // ans_tmp) // 2
if ans == 0:
    print(0)
else:
    if ans * ans_tmp >= m:
        print(int(ans))
    else:
        print(int(ans+1))

Submission status: Wrong Answer

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

from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
l=1

max2=0
min2=1000

for i in a:
    factor=(i^(i-1)).bit_length()
    max2=max(max2,factor)
    min2=min(min2,factor)
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

if l>m or min2!=max2:
    print(0)
else:
    ans=1 if l<=m else 0
    m-=l

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()))
A = sorted(set(A))

check = [-1 if (a//2) % 2 == 0 else 1 for a in A]
if abs(sum(check)) != len(A):
    print(0)
    exit()

# LCMを求めたい
LCM = 1
for a in A:
    gcd = GCD(LCM, a)
    LCM = LCM * a // gcd

ans = (M - LCM // 2) // LCM + 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=[i//2 for i in map(int,input().split())]
cnt=0
s=a[0]
while s%2==0:
  cnt+=1
  s//=2
for i in a[1:]:
  if i%(2**cnt)==0:
    print(0)
    exit()
ans=a[0]
for i in a[1:]:
  ans=lcm(ans,i)
print((M//ans)//2+1)

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=[i//2 for i in map(int,input().split())]
cnt=0
s=a[0]
while s%2==0:
  cnt+=1
  s//=2
for i in a[1:]:
  if i//(2**cnt)==0:
    print(0)
    exit()
ans=a[0]
for i in a[1:]:
  ans=lcm(ans,i)
print((M//ans)//2+1)

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=[i//2 for i in map(int,input().split())]
for i in a:
  if i%2==0:
    print(0)
    exit()
ans=a[0]
for i in a[1:]:
  ans=lcm(ans,i)
print(((M+2)//ans)//2)

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=[i//2 for i in map(int,input().split())]
for i in a:
  if i%2==0:
    print(0)
    exit()
ans=a[0]
for i in a[1:]:
  ans=lcm(ans,i)
print((M//ans-1)//2+1)

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=[i//2 for i in map(int,input().split())]
for i in a:
  if i%2==0:
    print(0)
    exit()
ans=a[0]
for i in a[1:]:
  ans=lcm(ans,i)
print(M//ans//2+1)

Submission status: Wrong Answer

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

N, M = map(int,input().split())
a = list(map(int,input().split()))
a = np.array(a)
a = a // 2

def solve(p, q):
    cnt = 1
    while p % 2 == 0 and q % 2 == 0:
        cnt <<= 1
        p >>= 1
        q >>= 1
    if (p - q) % 2 != 0:
        return 0
    return p * q * cnt // gcd(p, q)
k = reduce(solve, a)
if k == 0:
    print(0)
else:
    ans = (M / k + 1) // 2
    print(ans)

Submission status: Wrong Answer

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

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

l=1
for i in a:
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

ans=1 if l<=m else 0
m-=l

print(ans+max(0,m//(2*l)))

Submission status: Wrong Answer

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

if(all(A[0]%2 == a%2 for a in A)):
    pass
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

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

# lcd of a1*x1+n1 & a2*x2+n2
def lcd(a1, n1, a2, n2, M):
    # if a1*a2 == 0:
        # return M, M
    x1 = 0
    x2 = 0
    k1 = n1
    k2 = n2
    while (k1 != k2)&(k1<M+2)&(k2<M+2):
        if k1 < k2:
            x1 += max(1,(k2-k1)//a1)
            k1 = a1*x1 + n1
        else:
            x2 += max(1, (k1-k2)//a2)
            k2 = a2*x2 + n2
        # print(k1, k2)
    return k1, n_lcd(a1, a2)


def solve(N: int, M: int, a: "List[int]"):
    a = (list(set(a)))
    base = 1
    base_n = 0
    for i in a:        
        base_n, base = lcd(base, base_n, i, i//2, M)
        if base >= M:
            print(0)
            return 

    if base > M:
        print(0)
    else:
        print((M-base_n)//base + 1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

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

# lcd of a1*x1+n1 & a2*x2+n2
def lcd(a1, n1, a2, n2, M):
    if a1*a2 == 0:
        return M, M
    x1 = 0
    x2 = 0
    k1 = n1
    k2 = n2
    while (k1 != k2)&(k1<M+2)&(k2<M+2):
        if k1 < k2:
            x1 += max(1,(k2-k1)//a1)
            k1 = a1*x1 + n1
        else:
            x2 += max(1, (k1-k2)//a2)
            k2 = a2*x2 + n2
        # print(k1, k2)
    return k1, n_lcd(a1, a2)


def solve(N: int, M: int, a: "List[int]"):
    a = (list(set(a)))
    base = 1
    base_n = 0
    for i in a:        
        base_n, base = lcd(base, base_n, i, i//2, M)
        if base >= M:
            print(0)
            return 

    if base > M:
        print(0)
    else:
        print((M-base_n)//base + 1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

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

# lcd of a1*x1+n1 & a2*x2+n2
def lcd(a1, n1, a2, n2, M):
    if a1*a2 == 0:
        return M, M
    x1 = 0
    x2 = 0
    k1 = n1
    k2 = n2
    while (k1 != k2):
        if k1 < k2:
            x1 += max(1,(k2-k1)//a1)
            k1 = a1*x1 + n1
        else:
            x2 += max(1, (k1-k2)//a2)
            k2 = a2*x2 + n2
        # print(k1, k2)
        if (k1>M+2) or (k2>M+2):
            return M, M
    return k1, n_lcd(a1, a2)


def solve(N: int, M: int, a: "List[int]"):
    a = sorted(list(set(a)))
    base = 1
    base_n = 0
    for i in a:        
        base_n, base = lcd(base, base_n, i, i//2, M)
        if base >= M:
            print(0)
            return 

    if base > M:
        print(0)
    else:
        print((M-base_n)//base + 1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()