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 sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()

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

po = lcm_list(a)

p = -(-(M // po) // 2)

print(p)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#最小公倍数(least common multiple)
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 solve():
    n,m = list(map(int,input().split()))

    a = list(map(int,input().split()))
    a = list(map(lambda x:x//2,a))
    div_cnt = 0
    a0 = a[0]
    while a0%2==0:
        div_cnt+=1
        a0//=2
    two_pow_divcnt = 2**div_cnt
    for i in a:
        if i%two_pow_divcnt==1 or i%(two_pow_divcnt*2)==0:
            return 0
    base = lcm(*a)
    if base > m:
        return 0
    else:
        return (m+base)//(base*2)

if __name__ == '__main__':
    print(solve())

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_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
A = list(map(int,input().split()))
LCM = lcm_list(A)
ans = 1

while((ans * 2 - 1) * (LCM // 2) <= M):
    ans += 1

ans -= 1

if ans == 0:
    print(ans)
else:
    if max(A) > LCM:
        ans -= 1
    print(ans)

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_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
A = list(map(int,input().split()))
LCM = lcm_list(A)
ans = 1

while((ans * 2 - 1) * (LCM // 2) <= M):
    ans += 1

ans -= 1

if max(A) > LCM:
    ans -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#最小公倍数(least common multiple)
import fractions
from functools import reduce
def lcm_base(x, y):
    return ((x * y) // fractions.gcd(x, y))%(10**9+7)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def solve():
    n,m = list(map(int,input().split()))

    a = list(map(int,input().split()))
    a = list(map(lambda x:x//2,a))
    a1 = list(map(lambda x:x%2,a))
    if sum(a1) not in [0,n]:
        return 0
    else:
        base = lcm(*a)
        if base > m:
            return 0
        else:
            return (m+base)//(base*2)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
import fractions


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

lcm=A[0]
for i in range(1,n):
    lcm=lcm*A[i]//fractions.gcd(lcm,A[i])
    if lcm>m:
        print(0);exit()

if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

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

Submission status: Wrong Answer

Solution code:
import fractions


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

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

if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


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

lcm=lcm_list(A)
if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


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

lcm=lcm_list(A)
if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


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

a=lcm_list(A)
b=a//2

print((m-b)//a+1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


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

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


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

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(round(tmp // 2) + 1)
else:
    print(tmp // 2)

Submission status: Wrong Answer

Solution code:
import fractions

N, M = map(int, input().split())
l_in = list(map(int, input().split()))
d_two = l_in[0]
d_max = 0
flg = True
for i in l_in:
  if (i // d_two) % 2 == 0 or (d_two // i) % 2 == 0:
    flg = False

if flg:
  l_num = []
  lcm = 1
  for i in l_in:
    if i // 2 not in l_num:
      l_num.append(i // 2)
      lcm = lcm * (i // 2) // fractions.gcd(lcm, i // 2)

  d_max = M // lcm
  if d_max % 2 == 1:
    d_max += 1

print(d_max // 2)

Submission status: Wrong Answer

Solution code:
import fractions

N, M = map(int, input().split())
l_in = list(map(int, input().split()))
d_max = 0
if max(l_in) < M:
  l_num = []
  lcm = 1
  for i in l_in:
    if i // 2 not in l_num:
      l_num.append(i // 2)
      lcm = lcm * (i // 2) // fractions.gcd(lcm, i // 2)

  d_max = M // lcm
  if d_max % 2 == 1:
    d_max += 1

print(d_max // 2)

Submission status: Wrong Answer

Solution code:
import fractions

N, M = map(int, input().split())
l_in = map(int, input().split())
l_num = []
lcm = 1
for i in l_in:
  if i // 2 not in l_num:
    l_num.append(i // 2)
    lcm = lcm * (i // 2) // fractions.gcd(lcm, i // 2)

d_max = M // lcm
if d_max % 2 == 1:
  d_max += 1

print(d_max // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
lcm = lcm_list(a)
if lcm > m or lcm == 0:
    print(0)
else:
    lcm //= 2
    tmp = m // lcm + 1
    print(tmp // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
lcm = lcm_list(a)
if lcm == 0:
    print(0)
else:
    lcm //= 2
    tmp = m // lcm + 1
    print(tmp // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
lcm = lcm_list(a) // 2
tmp = m // lcm + 1
print(tmp // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
gcd = lcm_list(a) // 2
tmp = m // gcd
if tmp % 2 == 0:
    print(tmp // 2)
else:
    print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
gcd = lcm_list(a)
if gcd % 2 != 0:
    print(0)
else:
    tmp = m * 2 // gcd
    if tmp % 2 == 0:
        print(tmp // 2)
    else:
        print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

n, m = na()
a = na()
gcd = lcm_list(a)
tmp = m * 2 // gcd
if tmp % 2 == 0:
    print(tmp // 2)
else:
    print(tmp // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

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


tmp = M // half_lcm
if (tmp) & 1:
    print(tmp // 2 + 1)
else:
    print(tmp // 2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2

print(round(M / half_lcm / 2))

Submission status: Wrong Answer

Solution code:
import sys
import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]
half_lcm = lcm_list(a) // 2
if half_lcm > M:
    print(0)
    exit()

print(round(M / half_lcm / 2))

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np
import math
 
N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) // 2
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])
for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = a[0]
for i in range(1, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from fractions import gcd
n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
lcm = 1
b, t = 0, a[0]
while t % 2 == 0:
    t //= 2
    b += 1
for x in a:
    lcm = lcm // gcd(lcm, x) * x
    c, t = 0, x
    while t % 2 == 0:
        t //= 2
        c += 1
    if b != c:
        print(0)
        exit()
m = (m + 1) // 2
ans = (m + lcm - 1) // lcm
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from fractions import gcd
n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
lcm = 1
for x in a:
    lcm = lcm // gcd(lcm, x) * x
if lcm > m:
    print(0)
    exit()
m = (m + 1) // 2
ans = (m + lcm - 1) // lcm
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from fractions import gcd
n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
lcm = 1
for x in a:
    lcm = lcm // gcd(lcm, x) * x
if lcm > m:
    print(0)
    exit()
m //= 2
ans = (m + lcm - 1) // lcm
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from fractions import gcd
n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
lcm = 1
for x in a:
    lcm = lcm // gcd(lcm, x) * x
if lcm > m:
    print(0)
    exit()
lcm *= 2
print((m + lcm - 1) // lcm)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

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

A_lcm = lcm_list(A)

ans = (M + (A_lcm // 2)) // A_lcm

print(ans)

Submission status: Wrong Answer

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

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

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

    ans = a[0]

    for i in range(1, N):
        ans = ans // gcd(ans, a[i]) * a[i]
    
    tmp = M // ans
    if tmp&1:
        print(tmp//2 + 1)
    else:
        print(tmp//2)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

    ans = a[0]

    for i in range(1, N):
        ans = ans // gcd(ans, a[i]) * a[i]
    
    print(((M // ans) + 1) // 2)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

def lcm(nums):
    return np.prod(nums) / reduce(gcd, nums)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()
    
lcm = lcm(a)

if lcm <= M:
    ans = M // lcm
    print(math.ceil(ans / 2))
else:
    print(0)
    exit()

Submission status: Wrong Answer

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

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

def lcm(nums):
    return np.prod(nums) / reduce(gcd, nums)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

for i in range(len(a) - 1):
    if check_two(a[i]) != check_two(a[i + 1]):
        print(0)
        exit()

lcm = lcm(a)

if lcm <= M:
    ans = M // lcm
    print(math.ceil(ans / 2))
else:
    print(0)
    exit()

Submission status: Wrong Answer

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

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

def lcm(nums):
    return np.prod(nums) / reduce(gcd, nums)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

for i in range(len(a) - 1):
    if check_two(a[i]) == check_two(a[i + 1]):
        continue
    else:
        print(0)
        exit()

a = np.array(list(set(a)))
lcm = lcm(a)

if lcm <= M:
    ans = M // lcm
    print(math.ceil(ans / 2))
else:
    print(0)
    exit()

Submission status: Wrong Answer

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

def kouyaku(a,b):
    aa = max(a,b)
    bb = min(a,b)
    if bb == 0:
        return aa
    else:
        return kouyaku(bb,aa%bb)

g = 1
A = [a//2 for a in A]
for i in range(N):
    g = g//kouyaku(g, A[i])*A[i]
    if g > M:
        print(0)
        exit()
if g%2 == 0:
    print(0)
else:
    print((M//g+1)//2)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil

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

n, M = map(int, input().split())
A = tuple(map(lambda x: int(int(x)/2), input().split()))
scm_core = 1
for a in A:
    scm_core = lcm(scm_core, a)

print(ceil(M // scm_core / 2))

Submission status: Wrong Answer

Solution code:
from functools import reduce

INF = 10**9+1

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

B = [A[i]//2 for i in range(N)]

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

def LCM(a,b):
    return a*b//GCD(a,b)

def LCM_list(L):
    return reduce(LCM,L)

now = LCM_list(B)
if now <= M:
    lb,ub = 1,INF
    while lb < ub:
        mid = (lb + ub) // 2
        if now * mid <= M and now * (mid+1) > M:
            break
        elif now * mid > M:
            ub = mid
        else:
            lb = mid
    ans = (mid+1)//2
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import heapq
import math
n,m = map(int,input().split())
a = set([-i for i in map(int,input().split())])
a = list(a)
heapq.heapify(a)
x = []
for i in range(math.floor(-m/a[0]+1/2)):
    x.append(-a[0]*(2*i+1))
for i in range(1,len(a)):
    ai = -a[i]
    for j in x:
        if not (j % ai == 0 and i // ai % 2 == 1):
            x.remove(j)
print(len(x))

Submission status: Wrong Answer

Solution code:
import fractions

N, M = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]

lcm = 1
for num in A:
    lcm = lcm * num // fractions.gcd(lcm, num)
p_max = int(M*2 // lcm)
p_odd = int((p_max + 1) /2)
print(p_odd)

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)#数列に対しての最小公倍数

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

c = 0
while True:
    if a[0]%2:
        for i in range(1,n):
            if a[i]%2 == 0:
                print(0)
                exit()
        break
    else:
        for i in range(n):
            if a[i]%2:
                print(0)
                exit()
            a[i]//=2
        c += 1

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

Submission status: Wrong Answer

Solution code:
def cal(s,M,e,A):
  c=0
  for X in range(s,M,e):
    for k in A:
      if not (float(X-(k/2))/k).is_integer():
        break
    else:
      c+=1
  return c

N,M=map(int,input().split())
A=set(map(int,input().split()))
count0=len([x for x in A if x%4 == 0])
print(count0,len(A))

if count0==len(A):
  print(cal(0,M,2,A))
elif count0==0:
  print(cal(1,M,2,A))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
i=0
for X in range(M):
  for k in A:
    if not (float(X-(k/2))/k).is_integer():
      break
  else:
    i+=1
print(i)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
a=sorted(set(a))[::-1]
n=len(a)
b=a[0]
d=a[0]
ans=m
for i in range(n-1):
  c=b
  b=gcd(d,a[i+1])
  d=d*a[i+1]//b
  if ((c+a[i+1])//b)%2!=0:
    ans=0
  if ans==0:
    break

c=m//d-m//(2*d)
print(min(ans,c))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
a=sorted(set(a))[::-1]
n=len(a)
b=a[0]
d=a[0]
ans=m
for i in range(n-1):
  b=gcd(d,a[i+1])
  d=d*a[i+1]//b
  if ((a[i]+a[i+1])//b)%2!=0:
    ans=0
  if ans==0:
    break

c=m//d-m//(2*d)
print(min(ans,c))

Submission status: Wrong Answer

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

answer = 0
for i in range(1, m+1):
    condition_list = []
    for a in a_list:
        if a%2 == 0 and (i-a//2)%a==0 and (i-a//2)//a>0:
            condition_list.append(True)
        else:
            condition_list.append(False)
            break
    
    if all(condition_list):
        answer += 1
        
print(answer)

Submission status: Wrong Answer

Solution code:
import fractions

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

aset=set()
for a in alist:
  aset.add(a)
  
alist_uniq=[]
for a in aset:
  alist_uniq.append(a)
  
if len(alist_uniq)==1:
  print((M-alist_uniq[0]//2)//alist_uniq[0]+1)
else:
  lcm_as=1
  modulo=1
  for a in alist_uniq:
    if (a//2)%2==0:
      print(0)
      break
    else:
      lcm_as=lcm_as*a//fractions.gcd(lcm_as,a)
      modulo*=a//2
  else:
    #print(modulo,lcm_as)
    print((M-modulo)//lcm_as+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

aset=set()
for a in alist:
  aset.add(a)
  
alist_uniq=[]
for a in aset:
  alist_uniq.append(a)
  
if len(alist_uniq)==1:
  print(M//alist_uniq[0])
else:
  lcm_as=1
  modulo=1
  for a in alist_uniq:
    if (a//2)%2==0:
      print(0)
      break
    else:
      lcm_as=lcm_as*a//fractions.gcd(lcm_as,a)
      modulo*=a//2
  else:
    #print(modulo,lcm_as)
    print((M-modulo)//lcm_as+1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions as f
n,m=map(int,input().split())
A=list(map(int,input().split()))
a=A[0]
b=0
while a%2==0:
  a=a//2
  b=b+1
B=[0]*n
for i in range(n):
  B[i]=A[i]/(2**b)
  if B[i]!=int(B[i]) or B[i]%2==0:
    print(0)
    sys.exit()
G=1
for i in range(n):
  G=G*B[i]//(f.gcd(G,B[i]))
print(int((m+G*(2**(b-1)))//(G*(2**b))))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[a[i]//2 for i in range(n)]
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
x=reduce(lcm,b,1)
y=reduce(lcm,a,1)
if x>m:
  print(0)
else:
  z=(m-x)//y+1
  for i in b:
    if (x//i)%2==1:
      z=0
      break
  print(z)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[a[i]//2 for i in range(n)]
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
x=reduce(lcm,b,1)
y=reduce(lcm,a,1)
if x>m:
  print(0)
else:
  print((m-x)//y+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 lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

for i in a:
    half_a.append(i//2)

half_lcm = lcm_list(half_a)

count = 0
print(-(-(M//half_lcm)//2))

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

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

    lcm = get_lcm(half_A)

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

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

    print(math.ceil(M/(2*lcm)))



if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

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

    lcm = get_lcm(half_A)
    if lcm <= M:
        print(math.ceil(M/(2*lcm)))
    else:
        print(0)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
    from fractions import gcd
    from functools import reduce
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    
    def cnt_2(n):
        cnt=0
        while n>0:
            if n%2==0:
                cnt+=1
                n//=2
            else:
                return cnt
    
    def lcm(x,y):
      return x*y//gcd(x,y)
    
    before=cnt_2(a[0])    
    for i in range(1,n):
        after=cnt_2(a[i])
        if after!=before:
            print(0)
            exit()
        before=after
    
    
    a=[num//(2**before) for num in a]
    G=reduce(lcm,a)
    ans=(m//G+1)//2
    print(ans) 
  
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from fractions import gcd
    from functools import reduce
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    
    def cnt_2(n):
        cnt=0
        while n>0:
            if n%2==0:
                cnt+=1
                n//=2
            else:
                return cnt
    
    def lcm(x,y):
      return x*y//gcd(x,y)
    
    before=cnt_2(a[0])    
    for i in range(1,n):
        after=cnt_2(a[i])
        if after!=before:
            print(0)
            exit()
        before=after
    
    
    a=[num//(2**before) for num in a]
    print(a)
    G=reduce(lcm,a)
    ans=(m//G+1)//2
    print(ans) 
  
if __name__=='__main__':
    main()