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
import sys
n,m=map(int,input().split())
a=list(map(int, input().split()))

for i in range(n):
  a[i]=a[i]//2
  if a[i]%2==0:
    print(0)
    sys.exit()
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
print(((m+ans)//ans)//2)

Submission status: Wrong Answer

Solution code:
import fractions
def calc(n):
    return int(n * 0.5)
n, m = map(int, input().split())
a = set(list(map(int, input().split())))
half_a = list(map(calc, a))
count = 0
k = 3
ans = half_a[0]
for i in range(1, len(half_a)):
    ans = ans * half_a[i] // fractions.gcd(ans, half_a[i])
print(m//ans - (m//(ans*2)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
# N,M=5, 1000000000
# a=[6, 6, 2, 6, 2]
# N,M=3, 100
# a=[14, 22 ,40]


# N,M=2,50
# a=[6,10]
import fractions
import sys

a = list(map(lambda x: x /2, a))

ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
# print(ans)
# print(ans*2**(len(a)))
# if ans*2**(len(a))>M:
#     print(0)
#     sys.exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil


def main():
    N, M = map(int, input().split()[:2])
    A = sorted(set(map(int, input().split())))
    N = len(A)

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

    if lcm > M:
        print(0)
    else:
        print(ceil(M / (lcm * 2)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

num_list = list(map(int, input().split()))
ans_list = []

for i in range(len(num_list)):
    p = 0
    tmp_list = []
    while max_num > num_list[i]//2 * (2*p + 1):
        tmp_list.append(num_list[i]//2 * (2*p + 1))
        p += 1
    
    tmp_list = [k for k in tmp_list if k % num_list[i] == num_list[i]//2]
    
print(len(ans_list))

Submission status: Wrong Answer

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

count=0
b = 0

for i in range(M):
    a = i + 1
    j = a * 2
    for k in range(N):
        if  j % A[k] == 0:
            b = b + 1
        else:
            break
    if b == N:
        count = count + 1
    b = 0

print(count)

Submission status: Wrong Answer

Solution code:
import fractions
N,M = map(int,input().split())
nums = [int(s)/2 for s in input().split()]
ans = nums[0]
for i in range(1,N):
    ans = ans*nums[i]//fractions.gcd(ans,nums[i])
L = (int(M/ans)-1)/2
if L<0:
    print(0)
else:
    print(int(L)+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import fractions as math
from functools import reduce
flgk=False
flgg=False
def lcm_base(x, y):
    return (x * y) // math.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()))
A2=[]
for i in range(N):
    A2.append(A[i]//2)
    if A2[i]%2==0:
        flgg=True
    else:
        flgk=True

l=lcm_list(A2)

ans=M//l

if flgk and flgg:
    print(0)
else:
    if ans%2==1:
        print(max(ans//2+1,0))
    else:
        print(max(ans//2,0))

Submission status: Wrong Answer

Solution code:
import fractions
s=list(map(int,input().split()))
t=[int(i)//2 for i in input().split()]
ans = t[0]
a=0
for i in range(1,s[0]):
  if t[i]%2==0:
    break
  a+=1
  ans=ans*(t[i])//fractions.gcd(ans,t[i])
if a==s[0]-1:
  if (s[1]//ans)%2==0 and ans<=s[1]:
    print(int(s[1]//ans//2))
  elif (s[1]//ans)%2==1 and ans<=s[1]:
    print(int(s[1]//ans//2+1))
  else:
    print(0)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import sys, fractions
from functools import reduce
import numpy as np

ip = sys.stdin.readline

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)

N, M = map(int, ip().rstrip().split())
a = np.array(list(map(int, ip().rstrip().split())), dtype=np.int)

g, l = gcd_list(a), lcm_list(a)

if sum(a / g % 2) == N:
    if l/2 <= M:
        print(int((M-l/2)//l) + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
f = a[0]

cnt = 0
while f%2 == 1:
	cnt += 1
	f = f/2

for i in range(n):
	if (a[i]//(2**cnt)) % 2 == 0:
		print(0)
		exit(0)
	else:
		b.append(a[0]/2)

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

now = b[0]
for i in range(1, n):
	now = lcm(now, b[i])

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

def lcm(nums):
		return reduce(multiple, nums)
	
n,m=map(int,input().split())
a=list(map(lambda x: int(x)//2, input().split()))

ans=lcm(a)
print(m//ans-m//(ans*2))

Submission status: Wrong Answer

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

sys.setrecursionlimit(10000)

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


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


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


def lcmm(l):
    return reduce(lcm, l)


x = lcmm(a)
# print(x)

i = m / x
ans1 = -(-m // x)  # 切り上げ
ans2 = m // x  # 切り捨て

if i > ans2 + 0.5:
    print(ans1)
else:
    print(ans2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
def GCM(a, b):
  a, b = max(a,b), min(a, b)
  r = a % b
  if r == 0:
    return b
  else:
    return GCM(b, r)

def LCD(a, b):
  g = GCM(a, b)
  return (a//g)*b

N, M = map(int, input().split())
A = list(map(int, input().split()))
X_2 = A[0]
X = A[0]//2
for a in A[1:]:
  X_2 = LCD(X_2, a)
  X = LCD(X, a//2)
print(M//X-M//X_2)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
lcm = A[0]
ans = 0

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

if M >= lcm // 2:

    M -= lcm//2
    ans = 1+(M//lcm)
# print(lcm_half)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

n,m = map(int,input().split())
a = [int(i) for i in input().split()]

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

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

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

kizami = lcm_list(a)

a_hf = []

for i in range(n):
    a_hf.append(a[i]//2)

first = lcm_list(a_hf)

if m < first:
    print(0)
    exit()
else:
    print(1+(m-first)//kizami)

Submission status: Wrong Answer

Solution code:
import math

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

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

p = set()

flag = 0



ans = 0
tmp = factorization(A[0])
tmp2 = tmp[0][1]
for i in range(N):
    tmp = factorization(A[i])
    if tmp[0][1] != tmp2:
        flag = 1
        break
    o = 0
    for t in tmp:
        # o = [pow(t[0], i) for i in range(1,t[1]+1) ]
        p = p | set([pow(t[0], i) for i in range(1,t[1]+1) ])
q = 1
pp = list(p)
for i in range(len(pp)):
    q *= pp[i]

if q / 2 > M:
    ans =0
elif flag==0:
    minans = 1
    maxans = M
    cnt = 0
    i = M  //2
    while(cnt < 30):
        cnt += 1
        if q * (i * 2 + 1) // 2 > M :
            maxans = i
            i -= (maxans-minans) // 2
        else:
            minans = i
            i += (maxans-minans) // 2

    for j in range(4):

        if q*((i-2+j)*2 + 1) // 2 <= M:
            ans = (i-2+j)+1
        

print(ans)

Submission status: Wrong Answer

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

def main():
    _,M = map(int,input().split())
    A = tuple(int(i) for i in input().split())

    MINX = reduce(lcm, A)

    from math import ceil
    print(ceil(M/MINX))

def lcm(x, y):
        return (x * y) // gcd(x, y)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
from functools import reduce
import math

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

l = reduce(lcm, A)

if l >= (M*2):
  print(0)
else:
  print(math.ceil(M/l))

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

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

num = lcm_list([v // 2 for v in A])
ans = M // num
if num % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)

Submission status: Wrong Answer

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

a.sort()

s = set()

i = 0
while True:
    x = a[0] * (i + 0.5)
    if x == int(x):
        s.add(int(x))
    if x > m:
        break
    i += 1

for i in a[1:]:
    ss = set()
    for j in s:
        if j * 2 % i == 0:
            ss.add(j)
    s = s & ss
print(len(s))

Submission status: Wrong Answer

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

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

L=1
g=1


for i in range(0,n,2):
    L=lcm(L,a[i])
    g=lcm(g,a[i]//2)

ans=(m+g)//L-g//L
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

sm = 1
for i in range(n):
  sm = lcm(sm, a[i])
  if (sm > m):
    print(0)
    exit(0)
#print(sm)

m //= sm
m -= 1
m //= 2

print(m+1)

Submission status: Wrong Answer

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

ma = a[0]
for i in range(1, len(a)):
    ma = ma * a[i]

x = 0
for i in range(ma+1):
    is_count = True
    for j in range(len(a)):
        ans = i/a[j]
        f = ans - int(ans)
        if f != 0.5:
            is_count = False
            break
    if is_count:
        x = i
        break
if x == 0:
    print(0)
else:
    print(math.ceil(m/x/2))

Submission status: Wrong Answer

Solution code:
import fractions

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

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


def calcLCM(lst):
    ans = lst.pop()
    for val in lst:
        ans = ans * val // fractions.gcd(ans, val)
    return ans

lcm = calcLCM(set(A))
if lcm > M:
    print(0)
    exit()

ans = 0
sp = -1
for X in range(1, M+1):
    flg = False
    mitasu = []
    for ak in set(A):
        p = X/ak - 0.5
        if p.is_integer() and p > 0:
            flg = True
        else:
            flg = False
            break
    
    if flg:
        ans += 1
        sp = X
        break

if sp == -1:
    print(0)
else:
    ans = ans + M // calcLCM(set(A))
    print(ans)

Submission status: Wrong Answer

Solution code:
import collections as c
ip = lambda : map(int, input().split())
# ##############
N,M = ip()
a = list(ip())
for i in a:
    if i%4==0:
        print(0)
        exit()
from fractions import gcd
g = a[0]//2
for i in range(1,N):
    g = g*(a[i]//2)//gcd(g,a[i]//2)
print((M-g)//(2*g)+1)

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()))
a=[2]*10**5

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:
N,M = map(int, input().split())
A = list(map(int, input().split()))

A = list(set(A))

ans = 0
num = 0
a_max = max(A)
i_max = int(M/a_max)

for i in range(0,i_max+1):
  x = a_max * i + int(a_max/2)
  flag = True
  for a in A:
    if x%a == int(a/2):
      pass
    else:
      flag = False
      break
  if flag:
    num = x
    break
    
if num>0:
  maximum = 1
  for j in range(1,int(M/num)+1):
      if num*(2*j-1) <= M:
        maximum = j
      else:
        break
  ans = maximum
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(a):

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


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


m -= tmplcm//2
ans = m // tmplcm +1

print(max(ans,0))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random
import fractions


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def good(A, N):
    # A = sorted(A)
    ans = A[0]
    # for i in range(1, N):
    #     ans = fractions.gcd(A[i], ans)
    for i in range(1, N):
        ans = ans * A[i] // fractions.gcd(ans, A[i])
    return ans


def main():
    N, M = MI()
    a = LI()
    n = good(a, N)

    # print(n // 2, M)
    if n // 2 > M:
        print(0)
    else:
        print(2 * M // n // 2 + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline

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

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

x = b[0]
for i in range(1, len(b)):
    x = (x * b[i]) // gcd(x, b[i])

lcm = x

q = M // lcm
if q * lcm % 2 == 1:
    ans = q // 2 + 1
else:
    ans = q // 2
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

tmp = 1
for x in a:
    x //= 2
    tmp2 = x // fractions.gcd(tmp, x)
    M //= tmp2
    tmp *= tmp2

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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

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

n, m = map(int, input().split())
a_list = sorted(set(map(int, input().split())))
prod = 1
for a in a_list:
    prod *= a // 2
lcm = lcm_list(a_list)
if prod > m:
    print(0)
else:
    print((m - prod) // lcm + 1)

Submission status: Wrong Answer

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

import numpy as np
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

number = lcm(A)

ans = M // number

if ans == 0:
    print(ans)

else:
    print(ans + 1)

Submission status: Wrong Answer

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

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)


t = lcm(*A)
print(int(m//t + 0.5))

Submission status: Wrong Answer

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

a = list(set(a))


for i in range(1, 31):
    flag1 = False
    flag2 = False
    tmp = 2 ** i
    for j in a:
        if j % tmp == 0:
            flag1 = True
        else:
            flag2 = True
    if flag1 and flag2:
        print(0)
        exit()


candidate = 1
for i in a:
    candidate = candidate * i
    if candidate > M:
        print(0)
        exit()
tmp = (M // candidate)
if tmp % 2 == 0:
    tmp = tmp // 2
else:
    tmp = (tmp + 1) // 2

print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

A = list(map(lambda x: x // 2, A))


from functools import reduce

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)

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

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
    
LCM = lcm_list(A)

print(LCM)

ans = math.ceil(M / LCM)

if LCM == 0:
  print("No")
elif ans % 2 == 0:
  print(int(ans / 2))
else:
  print(ans // 2 + 1)

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 lcm(x, y):
    return (x * y) // gcd(x, y)

p = A[0]//2
q = A[0]
for i in range(1, N):
    # print(i)
    p = lcm(p, A[i]//2)
    q = lcm(q, A[i])
# print(p, q)

# n = ((M - p) / q) + 1
# print(int(n))

M -= p
# print(M)
print(M//q + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from sys import exit

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
while True:
    tmp_2 = [x % 2 for x in A]
    if tmp_2 == [0] * N:
        A = [x // 2 for x in A]
    elif tmp_2 == [1] * N:
        break
    else:
        print(0)
        exit()

lcm = A[0]
for i in range(1, N):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if A[i] % 2 == 0 or lcm > M:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
#!python3.4.3
from fractions import gcd
from decimal import Decimal, ROUND_HALF_UP

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

ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])

print(Decimal(str(m/ans)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Wrong Answer

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

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
a = list(map(int,input().split()))
my_gcd = 1
for i in range(n):
    my_gcd = lcm(my_gcd,a[i]//2)
#print(my_gcd)
ans = math.ceil((m/(my_gcd*2)))
if ans != 1:print(ans)
else: print(0)

Submission status: Wrong Answer

Solution code:
import sys
import fractions
N, M = map(int,input().split())
a = list(map(int,input().split()))
b = sorted([i/2 for i in a])
ans = b[0]
for i in range(1, N):
    ans = ans * b[i] // fractions.gcd(ans, b[i])
if b[0]%2 == 0:
    for i in b:
        if i%2 == 1:
            print(0)
            sys.exit()
    bmin = min(b)
    bmax = max(b)
    print(int(((M+bmin-bmax)/ans)/2+1))
elif  b[0]%2 == 1:
    for i in b:
        if i%2 == 0:
            print(0)
            sys.exit()
    bmin = min(b)
    bmax = max(b)
    print(int((M + bmin - bmax) / 2/ans + 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_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N, M = map(int, input().split())
    a2N = map(lambda s: int(s) // 2, input().split())

    #print(lcm_list(list(a2N)))
    print(M // lcm_list(list(a2N)) // -2 * -1)


main()

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
a = [int(i)//2 for i in input().split()]
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
num = M//ans
if num%2 == 0:
  print(num//2)
else:
  print(num-(num//2))

Submission status: Wrong Answer

Solution code:
import fractions
def calc(n):
    return int(n * 0.5)
n, m = map(int, input().split())
a = tuple(map(int, input().split()))
half_a = tuple(map(calc, a))
count = 0
k = 3
ans = half_a[0]
for i in range(1, len(half_a)):
    ans = ans * half_a[i] // fractions.gcd(ans, half_a[i])
print(m//ans - (m//(ans*2)))

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]    
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
flag = False
b = lcm(a)
while flag == False:
    for i in range(N):
        if (b // a[i]) % 2 == 1:
            flag = True
    if flag == False:
        b += b
if M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
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(*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]))
#print(B)
a = lcm(*B)
#print(a)

if a > M:
        print(0)
        exit(0)
        
for i in range(a,M+1,a):
    #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 (i / j)-0.5 > 0:
        break

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

Submission status: Wrong Answer

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

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

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

a=list((np.array(a))//2)

res = 1
for i in range(N):
    res = lcm(res,a[i])
    if res >= (10**12):
        print(0)
        exit()
#print(res)
if M < res:
    print(0)
    exit()
k = (M-res)//(2*res)+1
print(k)

Submission status: Wrong Answer

Solution code:
import numpy as np


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


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


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

M *= 2
for i, b in enumerate(a):
    if i == 0:
        v = b
    v = lcm(v, b)
    if v > M:
        print(0)
        exit()
print((M // v) // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


def inpl():
    return list(map(int, input().split()))


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


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


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


def count2(i, t=0):
    if i % 2 == 0:
        return count2(i // 2, t + 1)
    else:
        return t


N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = lcm_list(A)
c_2 = count2(A[0])
cc = 2**c_2
if any(a % cc != 0 for a in A):
    print(0)
else:
    print(((M // all_lcm) + 1) // 2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = a[i]//2
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)
ans = lcm_list(a)
p = 0
i = 1
for i in range(m,-1,-1):
    if i%ans == 0 and i //ans %2 == 1:
        break
      
    
print((i//ans)//2+1)

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd

def lcm(num_list):
    x = num_list[0]
    for i in range(1, len(num_list)):
        x = (x * num_list[i]) // gcd(x, num_list[i])
    return x

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

a_lcm = lcm(a)
ans = 0

if 2*m < a_lcm:
    ans = 0
else:
    ans += math.ceil(m / a_lcm)

print(ans)

Submission status: Wrong Answer

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


count = 0
inner = 0
s = {}

for i in range(M):
    for even in EvenList:
        r = even * (0.5 + i)
        if r < M:
            if r in s:
                s[r] = s[r] + 1
            else:
                s[r] = 1
            if s[r] >= N:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
a = list(set(map(int, input().split())))
print(a)
ans = []
#M = 104
for i in range(1, M + 1, 2):
  if all(list(map(lambda x: i / x - int(i / x) == 0.5, a))):
    ans.append(i)
    #print(i)
    if len(ans) == 2:
      break
#print(ans)
if len(ans) == 2:
  print((M -ans[0])// (ans[1] -ans[0])+ 1)
else:
  print(len(ans))

Submission status: Wrong Answer

Solution code:


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



def gcd(a,b):
    x = max([a,b])
    y = min([a,b])
    while y:
        x, y = y, x % y
    return x

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

# 全体の最大公約数, 最小で2
num = A[0]
for i in range(1,N):
    num = gcd(num, A[i])

# それぞれをnumで割った時の偶奇が異なれば、NG
odd = 0
even = 0
for i in range(N):
    if A[i]  % 2 == 0:
        even += 1
    else:
        odd += 1

if odd > 0 and even > 0:
    print(0)
else:
    # 半最小公倍数
    h = A[0] // 2
    # 最小公倍数
    n = A[0]
    for i in range(1,N):
        h = lcm(h, A[i]//2)
        n = lcm(n, A[i])
    if h == A[-1]:
        h *= 1.5

    if M < h:
        print(0)
    else:
        ans = 1
        M -= h
        ans += M // n
        print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))

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

b = [i//2 for i in a]
c = lcm_list(b)

if c > m:
    print(0)
else:
    d = m // c
    if d % 2 == 0:
        ans = d//2
    else :
        ans = d//2 + 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

Submission status: Wrong Answer

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

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

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

#N,Mの最小公倍数を求める
L = 1
for a in A:
    L = lcm(L,a)
if M//L <= 0:
    print(0)
else:
    print((M//L + 1)//2)

Submission status: Wrong Answer

Solution code:
input1 = input().split()
n = int(input1[0])
m = int(input1[1])
list_p = input().split()
count = 0
i = 1
for i in range(m):
  check = True
  for j in range(len(list_p)):
    if(i/int(list_p[j]) % 0.5 != 0):
      check = False
      break
  if(check):
    count = count + 1
print(int(count/2))

Submission status: Wrong Answer

Solution code:
import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
#ahalf = list(map(lambda x: x//2,a))
g = a[0]
for i in range(1,n):
    g = g * a[i] // fractions.gcd(g,a[i])
if g > m:
    print(0)
else:
    print(math.floor((m / (g/2) + 1) / 2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import fractions
from functools import reduce
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

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

def solve(N: int, M: int, a: "List[int]"):
    half = [0]*N
    for i in range(N):
        half[i] = a[i]//2

    # all odd?
    for i in range(N):
        if half[i] %2 == 1:
            continue
        else:
            break
    else:
        # 全部偶数
        lcm = lcm_list(a)
        print((M-lcm//2)//lcm + 1)
        return 
    
    for i in range(N):
        if half[i] %2 == 0:
            continue
        else:
            break
    else:
        # 全部偶数
        ma = max(half)
        for i in range(0,N):
            if ma%half[i] == 0 and (ma//half[i])%2 == 1:
                continue
            else:
                break
        else:
            lcm = lcm_list(a)
            print((M-lcm//2)//lcm + 1)
            return

    print(0)
    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 as f
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=a[0]
for i in range(n):
    c=(c*a[i])//(f.gcd(c,a[i]))
if c in a:
    print((m+max(a))//c)
else:
    print((m+max(a))//(c))

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

sm = 1
for i in range(n):
  sm = lcm(sm, a[i])
  if (sm > m):
    print(0)
    exit(0)
#print(sm)

m //= sm
m -= 1
m //= 2

print(m+1)