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:
N,M = map(int,input().split())
A = list(map(int,input().split()))
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    def p_prime(n): 
        prime = [2]
        for i in range(3,n+1):
            flag = 0
            for j in prime:
                if i%j == 0:
                    flag = 1
                    break
                if i**0.5 < j:
                    break
            if flag == 0:
                prime.append(i)
        return prime
 
    mod = 10**9+7
    prime = p_prime(int(mod**0.5+1))
    def soinsuu(M):
        a = {}
        for p in prime:
            count = 0
            while M%p ==0:
                count += 1
                M //= p
            if count > 0:
                a[p] = count
        if M != 1:
            a[M] = 1
        return a
 
    def LCM(A):
        from collections import defaultdict
        AA = defaultdict(int)
    
        for i in range(len(A)):
            tmp = soinsuu(A[i])
            for j in tmp:
                AA[j] = max(AA[j], tmp[j])
                
        L = 1
        for i in AA:
            L *= pow(i,AA[i])
            if L >= 10**9 +7:
                L = float('inf')
                break
        return L
 
    B = []
    twotwo = pow(2,log2)
    for i in A:
        B.append(i//twotwo)
    l = LCM(B)
    l *= pow(2,log2-1)
    ans =(M+l)//(2*l)
    
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd


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


input = sys.stdin.readline

N, M = map(int, input().split())
A = sorted(map(int, input().split()))
LCM = 1
for a in A:
    if a % 2 == 1:
        print(0)
        exit()
    LCM = lcm_base(LCM, a//2)
tmp = (M//LCM)
if tmp % 2 == 0:
    tmp = tmp//2
else:
    tmp = tmp//2+1
print(tmp)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
p = 0
for i in A:
  if i % 2 == 0:
    i //= 2
  else:
    p = 1
    break
L = A[0]
k = 0
while A[0] % 2 == 0:
  k += 1
  A[0] //= 2
for i in range(1, N):
  a, b = L, A[i]
  while b != 0:
    a, b = b, a % b
  b = A[i] // a
  L *= b
  cnt = 0
  while A[i] % 2 == 0:
    cnt += 1
    A[i] //= 2
  if cnt != k:
    p = 1
    break
if p == 1:
  S = 0
else:
  S = M // L - M // (2 * L)
print(S)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

def get_all_lcm(numbers):
    
    
    cache = {}
    value = 1
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    return value

def logic(m, value):
    x, x_mod = divmod(m, value)
    y, y_mod = divmod(x, 2)

    answer = y + y_mod
    return int(m // value - 1) // 2 + 1 
def logic2(M, value):
    return int(M // value - 1) // 2 + 1

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]

    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]

    evens = []

    for number in numbers:
        even = 0
        while number % 2 == 0:
            number //= 2
            even += 1
        evens.append(even)

    if max(evens) != min(evens):
        return 0
    
    cache = {}
    value = 1
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    answer = logic2(m, value)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

def get_all_lcm(numbers):
    
    cache = {}
    value = 1
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    return value

def logic(m, value):
    x, x_mod = divmod(m, value)
    y, y_mod = divmod(x, 2)

    answer = y + y_mod
    return answer 

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]

    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]

    evens = []

    for number in numbers:
        even = 0
        while number % 2 == 0:
            number //= 2
            even += 1
        evens.append(even)

    if max(evens) != min(evens):
        return 0
    
    cache = {}
    value = 1
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    answer = logic(m, value)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
from fractions import gcd
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

def fac2(x):
    r = 0
    while x%2==0:
        x //= 2
        r += 1
    return r

n,m = inm()
a = inl()
b = [x//2 for x in a]
r = fac2(a[0])
for i in range(1,n):
    if fac2(a[i] != r):
        print(0)
        exit()
lc = reduce(lambda x,y: (x*y)//gcd(x,y), b, 1)
print((m+lc)//(2*lc))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

N,M=map(int,input().split())
#List=list(map(lambda x:int(x)/2,input().split()))
List=list(map(int,input().split()))


LCM=1
cut2count=0
a=List[0]
while a%2==0:
    a/=2
    cut2count+=1

for i in List:
    i/=2
    LCM*=i/gcd(LCM,i)
        
    cut2countb=0
    b=i
    while b%2==0:
        b/=2
        cut2count+=1
    if cut2count!=cut2countb:
        print(0)
        exit()


#for i in List:
 #   if LCM/i%2==0:
  #      print(0)
   #     exit()

print(int(M//(LCM*2)+M%(LCM*2)//LCM))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

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

# process/output
b = list(filter(lambda x: x%2 == 0, A))
if len(b) > 1 and not reduce(lambda x, y: x == y, map(lambda x: x//2, b)):
    print(0)

else:
    a = lcm(A)
    if a > M:
        print(0)

    else:
        print(int(M/a-1)//2+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

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

# process/output
b = list(filter(lambda x: x/2 == 0, A))
if len(b) > 1 and not reduce(lambda x, y: x == y, map(lambda x: x//2, b)):
    print(0)

else:
    a = lcm(A)
    if a > M:
        print(0)

    else:
        print(int(M/a-1)//2+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

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

# process/output
a = lcm(A)
if a > M \
    or not reduce(lambda x, y: x == y, map(lambda x: x//2, A)):
    print(0)

else:
    print(int(M/a-1)//2+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
    n, m = LI()
    a = LI()
    for ai in a:
        if ai & 1:
            print(0)
            return


    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
    lc = lcm(list(set(a)))
    print((m + lc//2) // lc)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np

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

pre = a[0]
hpre = a[0] // 2
for v in a[1:]:
    pre = pre * v // gcd(pre, v)
    v //= 2
    hpre = hpre * v // gcd(hpre, v)
# print((m + pre//2) // pre)
# print((m - max(a) // 2) // pre)
# print((m - max(a) // 2), pre, hpre)
print((m + hpre) // pre)

# for i in range((m + pre//2) // pre):
#     x = (pre * (i + 1) - pre//2)
#     print(x, (2 * x - a) / (2 * a))
#
# xi = 1
# x = a[xi] // 2
# for i in range(3):
#     x += a[xi]
#     print(x, (2 * x - a) / (2 * a))
#
# print(a, pre)
# x = hpre
# print("---")
# for i in range(3):
#     print(x, (2 * x - a) / (2 * a))
#     x += pre


# x = a // 2 + a*2
# p = 4
#
# print(x)
# print((2 * x - a) / (2 * a))
# print(a * (p + 0.5))
#
# # x = a * (p + 0.5)
# # x = ap + a//2
# # x - a//2 = ap
# # x/a - 1/2 = p
# # (2x - a) / 2a = p

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np

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

pre = a[0]
for v in a[1:]:
    pre = pre * v // gcd(pre, v)
print((m + pre//2) // pre)

# x = a // 2 + a*2
# p = 4
#
# print(x)
# print((2 * x - a) / (2 * a))
# print(a * (p + 0.5))
#
# # x = a * (p + 0.5)
# # x = ap + a//2
# # x - a//2 = ap
# # x/a - 1/2 = p
# # (2x - a) / 2a = p

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import sys
import fractions
import functools

K, M = (int(x) for x in input().split())

A = [int(x) for x in input().split()]

A = [x for x in set(A)]
A.sort()

#print("A = " + str(A))#

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0
a_0 = A[0]
while a_0 % 2 == 0:
	a_0 /= 2
	div += 1

#print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(A)):
	div2 = 0
	a = A[i]
	while a % 2 == 0:
		a /= 2
		div2 += 1
	#print("A[" + str(i) + "] count = " + str(div2))#
	if div2 != div:
		print("0")
		sys.exit()

# Aのすべての整数の最小公倍数を計算する
A = [a // 2 for a in A]
lcm = functools.reduce(lambda a, b: a * b // fractions.gcd(a, b), A, 1)
#print("lcm = " + str(lcm))#

# 1以上M以下の最小公倍数の奇数倍の整数の個数を数える

print(-((-M // lcm) // 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

LCM=1
for i in List:
    LCM*=i/gcd(LCM,i)

for i in List:
    if LCM/i%2==0:
        print(0)
        exit

print(int(M//(LCM*2)+M%(LCM*2)//LCM))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

LCM=1
for i in List:
    LCM*=i/gcd(LCM,i)

for i in List:
    if LCM/i%2==0:
        print(0)
        exit

print(M//(LCM*2)+M%(LCM*2)//LCM)

Submission status: Wrong Answer

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

def binarySearch (arr, l, r, x): 
  if r >= l: 
    mid = l + (r - l)//2
    if arr[mid] == x: 
      return mid 
    elif arr[mid] > x: 
      return binarySearch(arr, l, mid-1, x)  
    else: 
      return binarySearch(arr, mid+1, r, x) 
  else: 
    return -1


n , m = list(map(int , input().split()))
arr = list(map(int , input().split()))
lcm = arr[0]
hash = [0]*n
for i in range(1,n):
  hcf = gcd(lcm, arr[i])
  lcm = (lcm*arr[i])//hcf 
arr.sort()
k=0
for i in range(0,n):
  if(binarySearch(arr , 0 , n-1 , arr[i]*2)!=-1):
    k=1
if k==1:
  print(0)
else:
  lcm = lcm//2
  sum = m//lcm
  if(sum%2==0):
    print(sum//2)
  else:
    print(int(sum//2+1))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  while b > 0:
    a, b = b, a % b
  return a
 
n , m = list(map(int , input().split()))
arr = list(map(int , input().split()))
lcm = arr[0]
for i in range(1,n):
  hcf = gcd(lcm, arr[i])
  lcm = (lcm*arr[i])//hcf 
lcm = lcm//2
sum = m//lcm
if(sum%2==0):
  print(sum//2)
else:
  print(int(sum//2+1))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from functools import reduce
import numpy as np
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, a: "List[int]"):

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b
        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)
    
    def lcm_base(a: int, b:int):
        return a*b // gcd_base(a,b)

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



    x = lcm(*a)

    t = x // 2

    if t > M:
        print(0)
        exit()

    ans = 1
    ans += (M-t)//x
    
    print(ans)

    return



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
from functools import reduce
import numpy as np
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, a: "List[int]"):

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b
        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)
    
    def lcm_base(a: int, b:int):
        return a*b // gcd_base(a,b)

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



    x = lcm(*a)
    
    if x > M:
        print(0)
        exit()

    t = x // 2
    ans = 1
    ans += (M-t)//x
    
    print(ans)

    return



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:
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
  
n,max = map(int,input().split())

arr = map(int,input().split())

l = reduce(lcm,arr)
halfl = l // 2

if l > max:
  result=0
else:
  result = (max - l//2) // l +1

print(result)

Submission status: Wrong Answer

Solution code:
import fractions

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

for i in range(n):
    now_num = a[i]
    now_idx = 0
    while now_num % 2 == 0:
        now_num //= 2
        now_idx += 1
    idx_num.append(now_idx)

if len(set(idx_num)) == 1:
    lcm = a[0]
    for j in range(len(a) - 1):
        lcm = (lcm * a[j + 1]) // (fractions.gcd(lcm, a[j + 1]) * 2)

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

else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

for i in range(n):
    now_num = a[i]
    now_idx = 0
    while now_num % 2 == 0:
        now_num //= 2
        now_idx += 1
    idx_num.append(now_idx)

if len(set(idx_num)) == 1:
    lcm = a[0]
    for j in range(len(a) - 1):
        lcm = (lcm * a[j + 1]) // (fractions.gcd(lcm, a[j + 1]) * 2)
    ans = m // lcm
    if ans % 2 == 0:
        print(ans // 2)
    else:
        print(ans // 2 + 1)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

for i in range(n):
    now_num = a[i]
    now_idx = 0
    while now_num % 2 == 0:
        now_num //= 2
        now_idx += 1
    idx_num.append(now_idx)

if len(set(idx_num)) == 1 and idx_num[0] % 2 == 1:
    lcm = a[0]
    for j in range(len(a) - 1):
        lcm = (lcm * a[j + 1]) // fractions.gcd(lcm, a[j + 1])

    ans = m // lcm
    print(ans + 1)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

for i in range(n):
    now_num = a[i]
    now_idx = 0
    while now_num % 2 == 0:
        now_num //= 2
        now_idx += 1
    idx_num.append(now_idx)

if len(set(idx_num)) == 1:
    lcm = a[0]
    for j in range(len(a) - 1):
        lcm = (lcm * a[j + 1]) // fractions.gcd(lcm, a[j + 1])

    ans = m // lcm
    print(ans + 1)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

for i in range(n):
    now_num = a[i]
    now_idx = 0
    while now_num % 2 == 0:
        now_num //= 2
        now_idx += 1
    idx_num.append(now_idx)

if len(set(idx_num)) == 1:
    lcm = a[0]
    for j in range(len(a) - 1):
        lcm = (lcm * a[j + 1]) // fractions.gcd(lcm, a[j + 1]) // 2

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

else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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


def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]
    cache = {}
    value = 1

    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]

    evens = []

    for number in numbers:
        even = 0
        while number % 2 == 0:
            number //= 2
            even += 1
        evens.append(even)

    if max(evens) != min(evens):
        return 0

    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    x, x_mod = divmod(m, 2)
    y, y_mod = divmod(x, value)

    answer = y
    if (y_mod * 2 + x_mod) >= value:
        answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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


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


def calc(n, m, A):
    # 2の因数個数チェック
    x = A[0]
    count2 = 0
    while x % 2 == 0:
        count2 += 1
        x = x/2

    for x in A:
        if x % 2**count2 != 0 or x % 2**(count2+1) == 0:
            return 0

    T = reduce(lcm, map(lambda x: x/2**count2, A))
    print(count2, T)
    return int((m/T + 1)/2)


ans = calc(n, m, A)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import functools
N, M = map(int, input().split())
A = [int(i) for i in input().split()]


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


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A)
hlcm = lcm//2
print(lcm, hlcm)

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

if hlcm > M:
    print(0)
else:
    print((M+hlcm)//hlcm//2)

Submission status: Wrong Answer

Solution code:
import fractions
import functools
N, M = map(int, input().split())
A = [int(i) for i in input().split()]


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


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A)
hlcm = lcm//2
# print(lcm, hlcm)
for a in A:
    if a % 2 == 1:
        print(0)
        exit()
    if lcm//a % 2 == 0:
        print(0)
        exit()

if hlcm > M:
    print(0)
else:
    print(M//hlcm//2+1)

Submission status: Wrong Answer

Solution code:
import fractions
import functools
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
for a in A:
    if a % 2 == 1:
        print(0)
        exit()


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


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A)
hlcm = lcm//2
# print(lcm, hlcm)

if hlcm > M:
    print(0)
else:
    print(M//hlcm//2+1)

Submission status: Wrong Answer

Solution code:
import fractions
import functools
N, M = map(int, input().split())
A = [int(i) for i in input().split()]


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


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A)
hlcm = lcm//2
# print(lcm, hlcm)

if hlcm*2 != lcm or hlcm > M:
    print(0)
else:
    print(M//hlcm//2+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]
    cache = {}
    value = 1
    
    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]
    
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    x, x_mod = divmod(m, 2)
    y, y_mod = divmod(x, value)
    
    answer = y
    if (y_mod * 2 +  x_mod) >= value:
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]
    cache = {}
    value = 1
    
    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]
    
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    x, x_mod = divmod(m, 2)
    y, y_mod = divmod(x, value)
    
    answer = y
    if (y_mod * 2 +  x_mod) > value:
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]
    cache = {}
    value = 1
    
    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]
    
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    x, x_mod = divmod(m, 2)
    y, y_mod = divmod(x, value)
    
    answer = y
    if (y_mod * 2 +  x_mod) > value:
        answer += 1
    print(answer)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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

def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]
    cache = {}
    value = 1
    
    numbers = [int(x) // 2 for x in input().rstrip("\n").split(" ")]
    
    for number in numbers:

        if not number in cache:
            value = lcm(value, number)
            cache[number] = 1
    #print(value)
    x, x_mod = divmod(m, 2)
    y, y_mod = divmod(x, value)
    
    answer = y
    if y > 0:
        if x_mod > 0 or y_mod > 0:
            answer += 1
    print(answer)

Submission status: Wrong Answer

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

# c = 0
# for i in range(1, M+1):
#     print(i, [i/a for a in A])
#     if all(i/a-i//a == 0.5 for a in A):
#         c += 1

# print(c)

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)
def lcm(a, b):
    return (a*b) // gcd(a, b)

b = [a//2 for a in A]

b_lcm = 1
for b_i in b:
    tmp = lcm(b_lcm, b_i)
    if b_lcm == tmp:
        print(0)
        exit()
    else:
        b_lcm = tmp

c = M//b_lcm
print(-(-c//2))

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
# N, M = 10000, 100000
# A = list(range(2, 2*10000, 2))
# print(A)

# c = 0
# for i in range(1, M+1):
#     print(i, [i/a for a in A])
#     if all(i/a-i//a == 0.5 for a in A):
#         c += 1

# print(c)

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

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

b = [a//2 for a in A]

b_lcm = 1
for b_i in b:
    b_lcm = lcm(b_lcm, b_i)
    # if b_lcm > 10**18:
    #     print(0)
    #     exit()

c = M//b_lcm
print(-(-c//2))

Submission status: Wrong Answer

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

# c = 0
# for i in range(1, M+1):
#     if all(i/a-i//a == 0.5 for a in A):
#         print(i, [i/a for a in A])
#         c += 1

# print(c)

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

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

b = [a//2 for a in A]

b_lcm = 1
for b_i in b:
    b_lcm = lcm(b_lcm, b_i)
    if b_lcm > 10**18:
        print(0)
        exit()

c = M//b_lcm
print(-(-c//2))

Submission status: Wrong Answer

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

def lcm(a,b):
    return a*b//gcd(a,b)
n,m = map(int,input().split())
l = list(map(int,input().split()))
lm = 1
lm_harf = 1
for i in l:
    lm = lcm(lm,i)
    lm_harf = lcm(lm_harf,(i//2))
print(m//lm_harf-m//lm)

Submission status: Wrong Answer

Solution code:
import fractions

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // fractions.gcd(t, l[i])
    return t

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

# process/output
a = lcm(A)

if a > M: 
    print(0)

else:
    print(int(M/a-0.5)+1)

Submission status: Wrong Answer

Solution code:
import fractions

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // fractions.gcd(t, l[i])
    return t

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

# process
a = lcm(A)
p = int(M/a-0.5)

# output
if p == 0: print(0)
else: print(p+1)

Submission status: Wrong Answer

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


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x*y//gcd(x, y)
    return reduce(lcm, iter)


N, M = map(int, input().split())
A = list(map(int, input().split()))
l = least_common_multiple(map(lambda x: x//2, A))
baisuu = M // l
if baisuu & 1:
    print((baisuu + 1)//2)
else:
    print(baisuu//2)

Submission status: Wrong Answer

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


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x*y//gcd(x, y)
    return reduce(lcm, iter)


N, M = map(int, input().split())
A = list(map(int, input().split()))
l = least_common_multiple(map(lambda x: x//2, A))
print(math.ceil(math.floor(M/l)/2))

Submission status: Wrong Answer

Solution code:
import math
import fractions


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


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

    while True:
        odd_flag = 0
        even_flag = 0
        for i in range(len(a)):
            if a[i] % 2 == 0:
                a[i] = a[i] / 2
                even_flag = 1
            else:
                odd_flag = 1

        if odd_flag > 0 and even_flag > 0:
            print(0)
            exit()
        elif even_flag == 0:
            break


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

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

    # print(lcm)

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
N,M= map(int,input().split())
A=[int(x) for x in input().split()]
def lcmpair(a,b):
    return (a*b)// fractions.gcd(a,b)
def lcm(List):
    return reduce(lcmpair,List,1)
lcmB = lcm(A) //2

crit = 0
pena = 0
num = A[0]
while num%2 != 0:
    crit +=1
    num = num//2
count = 0
for i in A:
    count = 0
    while i%2 !=0:
        count +=1
        i = i//2
    if count != crit:
        pena = 1

if lcmB > M:
    print(0)
elif pena ==1:
    print(0)
else:
    print(((M//lcmB)+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
N,M= map(int,input().split())
A=[int(x) for x in input().split()]
B = [x//2 for x in A]
def lcmpair(a,b):
    return (a*b)// fractions.gcd(a,b)
def lcm(List):
    return reduce(lcmpair,List,1)
lcmB = lcm(B)

crit = 0
pena = 0
num = A[0]
while num%2 != 0:
    crit +=1
    num = num//2
count = 0
for i in A:
    count = 0
    while i%2 !=0:
        count +=1
        i = i//2
    if count != crit:
        pena = 1

if lcmB > M:
    print(0)
elif pena ==1:
    print(0)
else:
    print(((M//lcmB)+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
N,M= map(int,input().split())
A=[int(x) for x in input().split()]
B = [x//2 for x in A]
def lcmpair(a,b):
    return a*b// fractions.gcd(a,b)
def lcm(List):
    return reduce(lcmpair,List,1)
lcmB = lcm(B)

crit = 0
pena = 0
num = A[0]
while num%2 != 0:
    crit +=1
    num = num//2
count = 0
for i in A:
    count = 0
    while i%2 !=0:
        count +=1
        i = i//2
    if count != crit:
        pena = 1

if lcmB > M:
    print(0)
elif pena ==1:
    print(0)
else:
    print(((M//lcmB)+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions
N,M= map(int,input().split())
A=[int(x) for x in input().split()]
B = []
test = []
count = 0
for i in range(N):
    B.append(A[i]//2)
l = B[0]
for i in range(1,N):
    l = l * B[i] // fractions.gcd(l,B[i])
quo = M // l
for i in range(N):
    while A[i]%2 !=0:
        count +=1
        A[i] //=2
    test.append(count)
    count = 0
T = set(test)
if len(T) != 1:
    print(0)
elif quo %2 == 1:
    print((quo+1)//2)
else:
    print(quo//2)