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

input1 = input()
input2 = input()

N = int(input1.split()[0])
M = int(input1.split()[1])

list_a_n = []
list_a_n = input2.split()
list_a_n = list(map(int,(set(list_a_n))))
how_many_2 = []

for a in range(len(list_a_n)):
    result = 0
    for b in range(30):
        if list_a_n[a] % 2 == 0:
            list_a_n[a] = list_a_n[a] / 2
            result += 1
        else:
            how_many_2.append(result)
            break


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

T = int(ans)    
t = M / T

print(int(t // 2 + t % 2))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
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.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = []
 
for i in range(N):
        '''
        a = factorization(A[i]) 
        B.append(A[i] // (2**a[0][1]))
        '''
        while A[i] % 2 == 0:
                A[i] //= 2
 
a = lcm(*A)
#print(a)
 
if a > M:
        print(0)
        exit(0)
'''
for i in range(a,M+1,a*2):
    #print(i)
    i = float(i)
    flag = 0
    for j in A:
        #print((i / j)-0.5)
        if ((i / j)-0.5).is_integer() == False:
            flag = 1
    if flag == 0 and 0 <= (i / j)-0.5:
        break
'''
print(int((M-a) // (a*2) + 1))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
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.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = []
 
for i in range(N):
        while A[i] % 2 == 0:
                A[i] //= 2
 
a = lcm(*A)
 
if a > M or a==1:
        print(0)
        exit(0)

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
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.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = []

a = lcm(*A) // 2

for i in range(N):
        while A[i] % 2 == 0:
                A[i] //= 2
 
if a > M or a==1:
        print(0)
        exit(0)

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
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.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = []

a = lcm(*A)

for i in range(N):
        while A[i] % 2 == 0:
                A[i] //= 2
 
if a > M or a==1:
        print(0)
        exit(0)

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

#小さい方から1000個の要素の中で、2で割り切れる回数が最も少ないものの、その回数を求める。
#sisu_2は(Aの全要素中の)最も大きい2で割り切れる回数でなければ問題ないので、小さい方から1000個だけ調べている。
#もしここでsisu_2が最も大きい2で割り切れる回数となってしまうと、44行目で間違った判定をしてしまう。
#(厳密な解法ではないが、これで通る。ちなみに100でも通った。)
sisu_2 = min([factorization(A[i])[0][1] for i in range(min(1000,N))]) 

#lcm_a = lcm(*A) // 2
lcm_a = 1
if (lcm_a % (2**sisu_2) == 0) or lcm_a > M: 
    #最小公倍数の2で割り切れる回数が、先に求めたsisu_2個より多かったらNG
    print(0)
    exit(0)
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

#if gcd(*A) % 2 != 0:
    #print(0)
    #exit(0)

#sisu_2 = factorization(A[0])[0][1] 
sisu_2 = min([factorization(A[i])[0][1] for i in range(min(1000,N))])

#lcm_a = lcm(*A)
#lcm_a_half = lcm_a // 2
lcm_a = lcm(*A) // 2
'''
l = []
sisu_a0 = 0
for i in range(N):
    sisu = 0
    while A[i]%2==0:
        A[i] //= 2
        sisu += 1
    
    if sisu_a0==0:
        sisu_a0 = sisu
    else:
        if sisu_a0!=sisu:
            print(0)
            exit()
'''
if (lcm_a % (2**sisu_2) == 0) or lcm_a > M:
#factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M:
#if lcm_a > M:
    print(0)
    exit(0)
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

#if gcd(*A) % 2 != 0:
    #print(0)
    #exit(0)

#sisu_2 = factorization(A[0])[0][1] 
sisu_2 = min([factorization(A[i])[0][1] for i in range(min(10,N))])

#lcm_a = lcm(*A)
#lcm_a_half = lcm_a // 2
lcm_a = lcm(*A) // 2
'''
l = []
sisu_a0 = 0
for i in range(N):
    sisu = 0
    while A[i]%2==0:
        A[i] //= 2
        sisu += 1
    
    if sisu_a0==0:
        sisu_a0 = sisu
    else:
        if sisu_a0!=sisu:
            print(0)
            exit()
'''
if (lcm_a % (2**sisu_2) == 0) or lcm_a > M:
#factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M:
#if lcm_a > M:
    print(0)
    exit(0)
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

def gcd_list(L):
    return reduce(gcd,L)

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

def lcm_list(L):
    return reduce(lcm,L)

N,M=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x//2,a))
ans=0

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

dev_pre=dev_cnt(a[0])

for i in range(1,N):
    if dev_pre!=dev_cnt(a[i]):
        print(0)
        exit()
    dev_pre=dev_cnt(a[i])

dev_num=dev_cnt(a[0])

a=list(map(lambda x:x//2**dev_num,a))
lcm_a=lcm_list(a)

i=1
X=lcm_a*i

ans=M//(2**dev_num)
ans=ans//lcm_a
ans=ans//2+1

print(ans)

'''
while 1:
    X=lcm_a*i
    if X>M/(2**dev_num):
        break
    ans+=1
    i+=2
'''

#print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

if gcd(*A) % 2 != 0:
    print(0)
    exit(0)

sisu_2 = factorization(A[0])[0][1] 

#lcm_a = lcm(*A)
#lcm_a_half = lcm_a // 2
lcm_a = lcm(*A) // 2

if (lcm_a % (2**sisu_2) == 0) or lcm_a > M:
#if factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M:
    print(0)
    exit(0)
else:
    '''
    print(int((M-lcm_a) // (lcm_a*2) + 1))
    '''
    x = M//lcm_a
    if x%2==1:
        print((x-1)//2+1)
    else:
        print(x//2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

if gcd(*A) % 2 != 0:
    print(0)
    exit(0)

sisu_2 = factorization(A[0])[0][1] 

#lcm_a = lcm(*A)
#lcm_a_half = lcm_a // 2
lcm_a = lcm(*A) // 2

if (lcm_a % (2**sisu_2) == 0) or lcm_a > M:
#if factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M:
    print(0)
    exit(0)
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

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

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

n,m = map(int, input().split())
a = list(map(lambda x:int(x)//2, input().split()))
t = f(a[0])
m >> t
l = 1
for x in a:
    if f(x) != t:
        print(0)
        quit()
    x >>= t
    l = l // gcd(l,x) * x
    if l > m:
        print(0)
        quit()

print((m//l+2-1)//2) # round up

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

n,m = map(int, input().split())
a = list(map(lambda x: int(x)//2 , input().split()))
l = reduce(lambda x,y:x//gcd(x,y)*y, a)
while l%2 == 0:
    l//=2
    m//=2
print(0 if l>m else (m//l+2-1)//2) # round up

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions as fr

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = a // 2

a_lcm = a[0]
for i in range(1, n):
    a_lcm = a_lcm * a[i] // int(fr.gcd(a_lcm, a[i]))

b_lcm = b[0]
for i in range(1, n):
    b_lcm = b_lcm * b[i] // int(fr.gcd(b_lcm, b[i]))

print(m // b_lcm - m // a_lcm)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [ 0 for i in range(n)]

a = input().split()

l = []

for i in range(m):
    for j in range(n):
        x1 = (int(a[j]) * (i + 0.5))
        if (x1 >= 1) and (x1.is_integer() == True) and (x1 <= m):
            l.append(x1)

l2 = []
for i in l:
    if l.count(i) == 2:
        l2.append(i)

print(len(l2)//n)

Submission status: Wrong Answer

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

def lcm(a, b):return a//gcd(a,b)*b
def lcm_list(x): return reduce(lcm, x)
def gcd_list(x): return reduce(gcd, x)

n,m = map(int, input().split())
# a = [*map(lambda x: int(x)//2 , input().split())]
a = list(map(lambda x: int(x)//2 , input().split()))
l = lcm_list(a)
if l <= m//2:
    print((m//l+2-1)//2) # round up
else:
    print(0)

Submission status: Wrong Answer

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

def lcm(a, b):return a//gcd(a,b)*b
def lcm_list(x): return reduce(lcm, x)
def gcd_list(x): return reduce(gcd, x)

n,m = map(int, input().split())
# a = [*map(lambda x: int(x)//2 , input().split())]
a = list(map(lambda x: int(x)//2 , input().split()))
l = lcm_list(a)
if l <= m:
    print((m//l+2-1)//2) # round up
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))
for i in range(N):
    a[i] //= 2
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        a = abs(a)
        b = abs(b)
        while b:
            a, b = b, a % b
        return a # int
    return a * b // gcd(a, b) # int
L = reduce(lcm,a)

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

Submission status: Wrong Answer

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

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

def main():
    _, m = map(int, input().split())
    a = tuple(map(int, input().split()))
    a_h = map(lambda x: x // 2, a)

    first = reduce(lambda x, y: (x * y) // gcd(x, y), a_h)
    var = reduce(lambda x, y: (x * y) // gcd(x, y), a)
    if m < first:
        print(0)
    else:
        print((m - first) // var + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def main():
    _, m = map(int, input().split())
    a = tuple(map(int, input().split()))
    a_h = map(lambda x: x // 2, a)

    first = reduce(lambda x, y: (x * y) // gcd(x, y), a_h)
    var = reduce(lambda x, y: (x * y) // gcd(x, y), a)
    print((m - first) // var + 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def main():
    _, m = map(int, input().split())
    a = tuple(map(int, input().split()))
    a_h = map(lambda x: x // 2, a)

    first = reduce(lambda x, y: (x * y) // gcd(x, y), a_h)
    print((m - first) // (first * 2) + 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[int(x)//2 for x in input().split()]

def lcm(a,b):
  if a>b:
    a,b=b,a
  if a==1:
     return b
  n=a*b
  while a!=0:
    b,a=a,b%a
  return n//b

f1,f2=a[0],a[0]
for i in range(1,N-1):
  f1|=a[i]
  f2&=a[i]
c=0
while f1&1==0:
  f1//=2
  c+=1
if f2&2**c==0:
  print(0)
  exit()

t=a[0]
for i in range(1,N):
  t=lcm(t,a[i])
  if t>M:
    print(0)
    break
else:
  print(M//t-M//(t*2))

Submission status: Wrong Answer

Solution code:
# 2020/01/10

from fractions import gcd

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

aa=list(map(lambda x: x//2,a))
lcm=aa.pop()
for e in aa:
    lcm=(lcm*e)//gcd(lcm,e)
print(-(-m//lcm//2) if m>lcm else 0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
if ans//2>m:print(0);exit()
print(m//ans//2+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
if ans//2>m:print(0);exit()
if (m-ans//2)%ans==0:print(m//ans//2)
else:print(m//ans//2+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
if ans//2>m:print(0);exit()
else:
    for i in A:
        if ans//2%i==0:print(0);exit()
    if (m-ans//2)%ans==0:print(m//ans//2)
    else:print(m//ans//2+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
if ans//2>m:print(0);exit()
print((m-ans//2)//ans+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    

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

if gcd(*A) % 2 != 0:
    print(0)
    exit(0)

sisu_2 = factorization(A[0])[0][1] 

lcm_a = lcm(*A) // 2

if (lcm_a // (2**(sisu_2-1)) % 2 == 0) or lcm_a > M:
    print(0)
    exit(0)
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N, M = map(int,input().split())
A = list(map(int,input().split()))
#B = []

sisu_2 = factorization(A[0])[0][1] 

lcm_a = lcm(*A) // 2

if (lcm_a // (2**(sisu_2-1)) % 2 == 0) or lcm_a > M:
    print(0)
    exit(0)

    '''
if a > M or a % 4 == 0:
        print(0)
        exit(0)

for i in range(a,M+1,a*2):
    #print(i)
    i = float(i)
    flag = 0
    for j in A:
        #print((i / j)-0.5)
        if ((i / j)-0.5).is_integer() == False:
            flag = 1
    if flag == 0 and 0 <= (i / j)-0.5:
        break
    '''
else:
    print(int((M-lcm_a) // (lcm_a*2) + 1))

Submission status: Wrong Answer

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

p = int(m/min(a))
x = []
for j in range(p):
    tmp = a[0]*(j+0.5)
    if not tmp%1 and tmp not in x:
        x.append(tmp)

for i in range(1,len(a)):
    y = []
    for j in range(p+1):
        tmp = a[i]*(j+0.5)
        if not tmp%1 and tmp in x:
            y.append(tmp)
    x = y
print(len(x))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[int(x)//2 for x in input().split()]

def lcm(a,b):
  if a>b:
    a,b=b,a
  if a==1:
     return b
  n=a*b
  while a!=0:
    b,a=a,b%a
  return n//b

t=a[0]
for i in range(1,N):
  t=lcm(t,a[i])
  if t>M:
    print(0)
    break
else:
  print(M//t-M//(t*2) if t%2 else 0)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[int(x)//2 for x in input().split()]

def lcm(a,b):
  if a>b:
    a,b=b,a
  if a==1:
     return b
  n=a*b
  while a!=0:
    b,a=a,b%a
  return n//b

t=a[0]
for i in range(1,N):
  t=lcm(t,a[i])
  if t>M:
    print(0)
    break
else:
  print(0 if t%2 else M//t-M//(t*2))

Submission status: Wrong Answer

Solution code:
from functools import reduce
 
n,m= map(int,input().split())
a_list = list(map(int,input().split()))
 
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
lcm_value = lcm_list(a_list)
 
print((m*2//lcm_value+1)//2)

Submission status: Wrong Answer

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

lcm = an[0]
for a in an[1:]:
    l = lcm*a//gcd(lcm, a)
    if not (l//lcm % 2 and l//a % 2):
        print(0)
        sys.exit()
    lcm = l
print((M//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
import os
import sys
from fractions import gcd

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))


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


A = np.array(A, dtype=int)
A //= 2

# l = reduce(lcm, A)
l = 1
for a in A:
    l = lcm(l, a)
    if l > M:
        print(0)
        exit()

# cnt = math.ceil((M // l) / 2)
cnt = (M // l + 1) // 2
print(cnt)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools


def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


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

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


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


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

def main():
    N,M = isRaw()
    As = isRaw()
    As2 = [a//2 for a in As]
    div2X =2
    while True:
        divResult = [a%div2X==0 for a in As]
        if sum(divResult) != len(As2):
            break
        div2X *=2
    div2X*=2
    if sum([a % div2X == 0 for a in As]) !=0:
        return 0
    lcm = lcm_list(As2)
    nCM = M//lcm
    return (nCM+1)//2

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

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


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b / gcd
    return lcm


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


A_lcm = A[0]
isValid = True

for a in A:
    if Per2(A[0]) != Per2(a):
        isValid = False
        break

if isValid:
    for i in range(1, N):
        A_lcm = LCM(A_lcm, A[i])
        hlcm = A_lcm //2
        if hlcm > M:
            isValid = False
            break

if isValid:
    M -= A_lcm // 2
    ans = 1 + (M // A_lcm)
    print(int(ans))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

a=list(set(a))

def count_2(n):
    c=0
    while n%2==0:
        c+=1
        n=n//2
    return c

l=a[0]//2
g=a[0]//2
cnt=[]
cnt.append(count_2(a[0]//2))
for i in range(1,len(a)):
    cnt.append(count_2(a[i]//2))
    g=gcd(g,a[i]//2)
    l=l*a[i]//(2*g)

cnt=set(cnt)

if len(cnt)>1:
    print(0)
    exit()

ans=(M+l-1)//(2*l)

print(ans)

Submission status: Wrong Answer

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


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b / gcd
    return lcm


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


A_lcm = A[0]
isValid = True

for a in A:
    if Per2(A[0]) != Per2(a):
        isValid = False
        break

if isValid:
    for i in range(1, N):
        A_lcm = LCM(A_lcm, A[i])
    if A_lcm > M * 2:
        isValid = False

if isValid:
    M -= A_lcm // 2
    ans = 1 + (M // A_lcm)
    print(int(ans))
else:
    print(0)

Submission status: Wrong Answer

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


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b / gcd
    return lcm


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


isValid = True
for a in A:
    if Per2(A[0]) != Per2(a):
        isValid = False
        break

if isValid:
    A_lcm = A[0]
    for i in range(1, N):
        A_lcm = LCM(A_lcm, A[i])
        if A_lcm // 2 > M:
            isValid = False
            break

if isValid:
    M -= A_lcm // 2
    ans = 1 + M // A_lcm
    print(int(ans))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

a=list(set(a))

def count_2(n):
    c=0
    while n%2==0:
        c+=1
        n=n//2
    return c

l=a[0]//2
g=a[0]//2
cnt=[]
cnt.append(count_2(a[0]//2))
for i in range(1,len(a)):
    cnt.append(count_2(a[i]//2))
    g=gcd(g,a[i]//2)
    l=l*a[i]//(2*g)

cnt=set(cnt)

if len(cnt)>1:
    print(0)
    exit()

ans=(M-l)//(2*l)+1

print(ans)

Submission status: Wrong Answer

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


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b / gcd
    return lcm


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

isValid = True
for a in A:
    if Per2(A[0]) != Per2(a):
        isValid = False
if isValid:
    A_lcm = A[0]
    for i in range(1, N):
        A_lcm = LCM(A_lcm, A[i])
        if A_lcm // 2 > M:
            isValid = False
            break
if isValid:
    M -= A_lcm // 2
    ans = 1 + M // A_lcm
    print(int(ans))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[int(x)//2 for x in input().split()]

def lcm(a,b):
  if a>b:
    a,b=b,a
  if a==1:
     return b
  n=a*b
  while a!=0:
    b,a=a,b%a
  return n//b

t=a[0]
for i in range(1,N):
  t=lcm(t,a[i])
  if t>M:
    print(0)
    break
else:
  print(M//t-M//(t*2))

Submission status: Wrong Answer

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


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b / gcd
    return lcm


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


for a in A:
    if Per2(A[0]) != Per2(a):
        print(0)
        break
else:
    A_lcm = A[0]
    for i in range(1, N):
        A_lcm = LCM(A_lcm, A[i])
        if A_lcm // 2 > M:
            print(0)
            break
    else:
        ans = M - (A_lcm // 2)
        ans = ans // A_lcm
        ans += 1
        print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math
n, m = map(int, input().split())
#x = list(map(int , input().split()))
x = list(map(lambda x: int(x)//2 , input().split()))

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

all_lcm = x[0]
for xi in x:
    all_lcm = lcm(all_lcm, xi)

def my_round(x, d=0):
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x)))/p

s = m // all_lcm
t = m // (2 * all_lcm)
print(s-t)

#print( round(m / all_lcm ))
#print( int(my_round(m / all_lcm)) )