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

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])
if num % 2 == 0:
    print(M // num // 4)
else:
    print(M // num // 2 + 1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
A=list(map(int,input().split()))
def gcd(x1,x2):
    a=min(x1,x2)
    b=max(x1,x2)%a
    while not b==0:
        ta=b
        b=a%b
        a=ta
    return a

def lca(l):
    lc=1
    for i in range(len(l)):
       g=gcd(lc,l[i])
       lc=lc*l[i]//g
    return lc

end=False
for i in range(N):
    A[i]=A[i]//2
    if A[i]%2==0:
        end=True
        break
if end:
    print(0)
else:
    l=lca(A)
    ans=0
    m=M-l
    if m>=0:
        ans+=1
        ans+=(m//(l*2))
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

count = 0

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

if k > m:
  print("0")
  exit()

l = m % k

q = (l//a[0])-0.5

while q < 1:
  q += 1

q *= a[0]
q = int(q)

count = (m-q)//k

count += 1

print(int(count))

Submission status: Wrong Answer

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

a=list(set(a))
sa=1
p=0
for i in range(len(a)):
    m=m/a[i]

if m<1:
    print("0")
else:
    print(int(m)+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(set(a))
l = 1
s = 0
h = []
ans = 0
for i in a:
  h.append(i//2)
for j in range(m):
  for k in range(len(a)):
    if j-h[k]<0:
      break
    if (j-h[k])%a[k]:
      break
  if not (j-h[k])%a[k]:
    s = j
    break
for x in a:
  l*=x
r = l//reduce(fractions.gcd, a)
ans = (m-s)//r
if ans:
  ans+=1
print(ans)

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 gcd_list(numbers):
    res = 1
    for n in numbers:
        res = lcm(n, res)
    return res


N, M = map(int, input().split())
a = list(map(int, input().split()))
A = gcd_list(a)
a = list(map(lambda x:x//2, a))
B = gcd_list(a)
print(M//B-M//A)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

[n, m] = get_ints()
a = get_ints()

def small_lcm(x, y):
    if x is None or y is None:
        return None
    ans = x * y // gcd(x, y)
    return ans if ans <= m else None

l = reduce(lambda n, m: n * m // gcd(n, m), map(lambda x: x // 2, a))
if l is None:
    print(0)
    exit(0)
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd #なおす
n, m = map(int, input().split())
a = list(map(int, input().split()))

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

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

a = [i//g for i in a]
print(((m//g)+1)//2)

Submission status: Wrong Answer

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

if M >= (k // 2):
    ans += 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
import functools


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


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


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


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


lcm = lcm(A2)
n = 1
cnt = 0
num = lcm

if 0 < num <= m:
    odd = m // lcm
    if odd % 2 == 1:
        cnt = (odd + 1) // 2
    else:
        cnt = odd // 2
print(cnt)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
import fractions

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 = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a = [_a / 2 for _a in a]

l = int(lcm_list(a))
if l > M:
  answer = 0
else:
  answer = int((M / l) // 2 + 1)

print(answer)

Submission status: Wrong Answer

Solution code:
import fractions as math
n,m = map(int,input().split())
lst1 = list(map(int,input().split()))
lst1 = list(set(lst1))
ans,p = 0,0
lst1.sort(reverse=True)

#同じく最小公倍数
def lcmlist(l):
    a = l[0]//2
    for i in range(len(l)):
        a = a*(l[i]//2)//math.gcd(a,l[i]//2)
    return a

if len(lst1) == 1:
    syoko = lst1[0]//2
else:
    syoko = lcmlist(lst1)


if syoko > m:
    print(0)
    exit()
ans += 1

m -= syoko
ans += m//(syoko*2)
"""
p += syoko
while p <= m:
    p += syoko*2
    ans += 1
"""
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
d = defaultdict(int)

sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = list(set(A))

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

A_fac = [fctr1(val) for val in A]

max2 = max([val[0][1] for val in A_fac])

for vals in A_fac:
    for val in vals:
        if val[0] == 2: continue
        d[val[0]] = max(d[val[0]], val[1])

lcm = 1
for key, val in d.items():
    lcm *= (key**val)
lcm *= (2**max2)

if max2%2 == 0:
    lcm //= 2

div = M//lcm

if div + (lcm//2) <= M:
    print(div+1)
else:
    print(div)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
import copy
def lcm(x, y):
    return (x*y)//fractions.gcd(x, y)

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=copy.copy(a)
count=n
while count!=0:
  count=0
  for i in range(n):
    if b[i]%2==0:
      b[i]=b[i]//2
      count+=1
  if len(set(b))!=n:
    print(0)
    sys.exit()

for i in range(n):
  a[i]=a[i]//2
L=a[0]
for i in range(1,n):
  L=lcm(L,a[i])
  if L>=10**9+1:
    print(0)
    sys.exit()

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

Submission status: Wrong Answer

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

from fractions import gcd
import functools

l = functools.reduce(lambda a, b: a * b // gcd(a, b), As) >> 1

i = 2
while not (l & (i - 1)):
    i <<= 1
i = (i >> 1) - 1

fg = False
if i > 0:
    for a in As:
        if a & i:
            fg = True
            break

if fg:
    print(0)
else:
    print(M // l - M // (l * 2))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)
def lcm(a,n,m):
    ans = a[0]
    for i in range(1,n):
        ans = (ans * a[i])/(gcd(a[i],ans))
        if ans > 10**18:
            return -1
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)


start = l//2
# print(start)
ans = (m - (start))//l
# print(ans)
if ans < 0 or l==-1:
    print(0)
else:
    ans += 1
    print( round(ans) )

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = set(A)
power = 1
for b in B:
    power *= b//2

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)

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

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

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

l = 1
for i in range(N):
  l = lcm(l, A[i])

if l//2 > M:
  print(0)
  quit()
  
M += l // 2

print(M//l)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n, m = map(int, input().split())
A = set(map(lambda x: int(x)//2, input().split()))
if max(A) > m:
  print(0)
g = gcd_list(A)
l = lcm_list(A)
if (l//g)%2 == 0:
  print(0)
else:
  print(((m//l)+1)//2)

Submission status: Wrong Answer

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

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


# print(a)
a = a // 2
# print(a)

# count = 0
# for i in range(1, M+1):



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

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

# print(M)
# print(lcm(*a))
print((M // lcm(*a) + 1 ) // 2)
# print(lcm(*a))

Submission status: Wrong Answer

Solution code:
import fractions
N,M = map(int,input().split())
a_list = list(map(int,input().split()))
lcm = a_list[0]
for i in range(1, N):
    lcm = lcm * a_list[i] // fractions.gcd(lcm, a_list[i])
#print(lcm)
lcm //=2
if(lcm>M):
	print(0)
	exit()
print(M//lcm//2+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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


def main():
    N, M = map(int, input().split())
    numbers = list(map(int, input().split()))
    numbers = set(numbers)
    if 2 in numbers:
        numbers.remove(2)

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

    lcm = lcm_list(numbers)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions as f
from functools import reduce

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

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

saibai = lcm_list(a) // 2
print(saibai)

if saibai == 0:
  print(0)
else:
  if (m // saibai) % 2 == 0:
    print(int((m//saibai)//2))
  else:
    print(int((m//saibai)//2) + 1)

Submission status: Wrong Answer

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

a=list(set(a))
sa=1
p=0
for i in range(len(a)):
    m=m//a[i]
if m<1:
    print("0")

else:
    print(int(m)+1)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    
    # 重複削除
    Ad = list(set(A))
    Ad.sort()
    n = len(Ad)
    
    
    condis = [x for x in range(int(Ad[-1]*1.5), M, Ad[-1])]
    
    for i in range(n-1):
        new_condis = []
        for c in condis:
            if (c - Ad[i]*0.5) % Ad[i] == 0:
                new_condis.append(c)
        condis = new_condis
        
    print(len(condis))
    
main()

Submission status: Wrong Answer

Solution code:
import fractions
import sys
import copy
def lcm(x, y):
    return (x*y)//fractions.gcd(x, y)

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=copy.copy(a)
count=n
while count==n:
  count=0
  for i in range(n):
    if b[i]%2==0:
      b[i]=b[i]//2
      count+=1
  if len(set(b))!=n:
    print(0)
    sys.exit()

for i in range(n):
  a[i]=a[i]//2
L=a[0]
for i in range(1,n):
  L=lcm(L,a[i])
  if L>=10**9+1:
    print(0)
    sys.exit()

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = map(int, set(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(((2*m//t) + 1)//2)

Submission status: Wrong Answer

Solution code:
N,M=4,1000000000
A=[2,6,10,18]
def gcd(x1,x2):
    a=min(x1,x2)
    b=max(x1,x2)%a
    while not b==0:
        ta=b
        b=a%b
        a=ta
    return a

def lca(l):
    lc=1
    for i in range(len(l)):
       g=gcd(lc,l[i])
       lc=lc*l[i]//g
    return lc

end=False
for i in range(N):
    A[i]=A[i]//2
    if A[i]%2==0:
        end=True
        break
if end:
    print(0)
else:
    l=lca(A)
    ans=0
    m=M-l
    if m>=0:
        ans+=1
        ans+=(m//(l*2))
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = set(map(int, inputs[1].split()))
B = list(map(lambda x: x//2, A))

C = []
sup = 2*max(A)
for b in B:
    p = 0
    x = b*1
    c = {0}
    while x <= sup:
        c.add(x)
        p += 2
        x = b*(p + 1)
    sup = max(c)
    C.append(c)
    
c = C[0]
for ck in C[1:]:
    c &= ck
c.discard(0)
if c == set():
    print(0)
else:
    print((m // min(c) + 1) // 2)

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])
if num % 2 == 0:
    print(M // (num // 2) // 2)
else:
    print(M // num // 2 + 1)

Submission status: Wrong Answer

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

from fractions import gcd
import functools

l = functools.reduce(lambda a, b: a * b // gcd(a, b), As) >> 1

i = 2
while not (l & (i - 1)):
    i <<= 1
i = (i >> 1) - 1

fg = False
if i > 0:
    for a in As:
        if not (a & i):
            fg = True
            break

if fg:
    print(0)
else:
    print(M // l - M // (l * 2))

Submission status: Wrong Answer

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

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

L=1
g=1


for i in range(0,n):
    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:
from functools import reduce
from fractions import gcd
import sys

sys.setrecursionlimit(1000000)

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

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

Submission status: Wrong Answer

Solution code:
import math
import fractions


N, M = map(int, input().split())
a_i = list(map(int, input().split()))
half_a_i = []

for i in a_i:
    i //= 2
    half_a_i.append(i)

lcm = half_a_i[0]

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



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

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])
bb = set(b)
bb = list(b)
ans = bb[0]
for i in range(1, N):
    ans = ans * bb[i] // fractions.gcd(ans, bb[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:
n, m = list(map(int, input().split()))
A = sorted(set(map(int, input().split())),reverse=True)

import functools
import fractions

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

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

l = lcm_list(A)

print((m+l//2)//l)

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

kobai=lcm_list(list(map(lambda x:int(x/2),a_list)))

cnt=0
i=1
x=kobai*i
while x < M:
    x=kobai*i
    i+=2
    if x < M:
        cnt+=1

print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    
    # 重複削除
    Ad = list(set(A))
    Ad.sort()
    n = len(Ad)
    
    
    condis = [x for x in range(int(Ad[-1]*1.5), M, Ad[-1])]
    print(condis)
    
    for i in range(n-1):
        new_condis = []
        for c in condis:
            if (c - Ad[i]*0.5) % Ad[i] == 0:
                new_condis.append(c)
        condis = new_condis
        
    print(len(condis))
    
main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    b = [i >> 1 for i in a]
    c = [i&1 for i in b]
    c.sort()
    while 1:
        if c[0] == 1:
            break
        if c[0] == 0 and c[-1] == 1:
            print(0)
            return
        b = [i >> 1 for i in b]
        c = [i&1 for i in b]
        c.sort()
    l = b[0]
    for i in b[1:]:
        if l&1 != i&1:
            print(0)
            return
        g = gcd(l,i)
        l = l*i//g
        if l > m:
            print(0)
            return
    L = l
    l = 0
    r = m+1
    while r-l > 1:
        x = (l+r) >> 1
        if (2*x-1)*L <= m:
            l = x
        else:
            r = x
    print(l)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import fractions as f
from functools import reduce

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

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

saibai = int(lcm_list(a) // 2)

if saibai == 0:
  print(0)
else:
  if int(m//saibai) % 2 == 0:
    print(int((m/saibai)//2))
  else:
    print(int((m/saibai)//2) + 1)

Submission status: Wrong Answer

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

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

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)
b = lcm_list(a)

if b//2 > m:
    print(0)
    exit()

c =(m+(b-1))//b 
print(c)

Submission status: Wrong Answer

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

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


print(a)
a = a // 2
print(a)

# count = 0
# for i in range(1, M+1):



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

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

# print(M)
# print(lcm(*a))
print((M // lcm(*a) + 1 ) // 2)
# print(lcm(*a))

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, len(A)):
    # 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:
import math
def main():

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted([a // 2 for a in A])
    if max(A) > M: return 0

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

    prev = 1
    for i in range(len(A)):
        c = gcd(prev, A[i])
        prev = (prev // c) * A[i]

    return (M // prev  + 1) // 2

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from fractions import gcd

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A):
    b = A[0] % 4
    for a in A:
        if a % 4 != b:
            error_print('a')
            return 0
    c = set(2 ** i for i in range(3, 50))

    A = set(A)
    for a in A:
        if a in c:
            return 0
    d = reduce(gcd, A)
    d = reduce(lambda x, y: x * y//d, A)
    ans = 0
    if M - d//2 > 0:
        ans = (M-d//2) // d
    if d // 2 < M:
        ans += 1

    return ans


def slv2(N, M, A):
    ans = set()
    A = A[:]
    a = A.pop()
    b = a // 2
    while b <= M:
        ans.add(b)
        b += a

    print(sorted(ans))
    while A:
        a = A.pop()
        b = a // 2
        tmp = set()
        while b <= M:
            tmp.add(b)
            b += a
        ans = ans & tmp
        print(sorted(tmp))
    return len(ans)

def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))
    # print(slv2(N, M, A))

    # N = 2
    # M = 1000
    # A = [random.randint(1, 5) * 4 for _ in range(N)]
    # A = [16, 40]
    # print(A)
    # # print(slv(N, M, A))
    # print(slv2(N, M, A))

if __name__ == '__main__':
    main()

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()))

A = list(set(A))

t = 1
for a in A:
    t = lcm(t, a)

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)
def lcm(a,n,m):
    ans = a[0]
    for i in range(1,n):
        ans = (ans * a[i])/(gcd(a[i],ans))
        if ans > 10**18:
            return -1
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)


start = l//2
# print(start)
ans = (m - (start))/l
# print(ans)
if ans < 0 or l==-1:
    print(0)
else:
    ans += 1
    print( round(ans) )

Submission status: Wrong Answer

Solution code:
def get_gcd(a, b):
    a, b = max(a, b), min(a, b)
    while b != 0:
        a, b = b, a % b
    return a

def get_lcm(a, b):
    return a * b // get_gcd(a, b)


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

B = A[0]

if sum([a % 2 != 0 for a in A]) > 0:
    print(0)
else:
    for b in A[1:]:
        pass
        B = get_gcd(B, b)
    print(max(0, int((M + 0.5 * B) // B)))

Submission status: Wrong Answer

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

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
#a,bの最小公倍数
def lcm(a, b):
  return a * b // gcd (a, b)

div1,div2=1,1
for a in A:
  div1=lcm(div1,a//2)
  div2=lcm(div2,a)
ans=m//div1 - m//div2
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

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

n,m = LI()
a = LI()
b = [i//2 for i in a]
for i in range(n):
    if b[i] % 2 == 0:
        print(0)
        quit()
if n == 1:
    lb = b[0]
else:
    lb = lcm(b[0],b[1])

for i in range(2,n):
    lb = lcm(lb,b[i])

if lb > m:
    print(0)
    quit()

ans = m//lb//2 + (m // lb) %2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from fractions import gcd

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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 = rl()
a = list(set(rl()))
a.sort()
A = np.array(a)
B = A // 2
if any(B%2==0) and any(B%2==1):
    print(0)
    exit()

b = list(B)
ans = lcm(b)
if ans > M:
    answer = 0
else:
    answer = 1 + (M-ans)//(2*ans)

print(answer)

Submission status: Wrong Answer

Solution code:
def main():
    import math
    import fractions
    import sys
    input = sys.stdin.readline

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

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

    num = 1
    for i in range(n):
        num = lcm(num, a[i])
    ans = math.floor(m // num + 0.5)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

sum = 0
for m in range(1,M+1):
    temp = True
    for n in range(N):
        if (2*m/A[n]-1)%2 == 0 and 2*m/A[n]-1>0:
            None
        else:
            temp = False
            break

    if temp == True:
        sum += 1
print(sum)

Submission status: Wrong Answer

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

n,m=map(int,input().split())
a=np.array(list(map(int,input().split())))
a=a//2
def lcm(x,y):
    return (x*y)//f.gcd(x,y)
def lcm_list(num):
    return reduce(lcm,num,1)
l=lcm_list(a)
ans=m//l

#奇数を取り除く
ans=ans//2+1
print(ans)

Submission status: Wrong Answer

Solution code:
# cook your dish here
def gcd(a,b):
    #print(a,b)
    if a==0:
        return b
    else:
        return gcd(b%a,a)
def lcm(a,b):
    return int(a*b/gcd(a,b))
#def sq2(a,b):
    
def sq(a,b):
    if a>b:
        d=b**(1.0/2)
        if (d).is_integer() and a%b==0 and b!=1:
            return False
    elif b>a:
        d=a**(1.0/2)
        if (d).is_integer() and b%a==0 and a!=1:
            return False
    else:
        d=a**(1.0/2)
        if (d).is_integer() and a!=1:
            return False
    return True
#print(lcm(2,30))
try:
    for t in range(int(input())):
        ar=list(map(int, input().split()))
        sm=0
        for i in range(1,ar[0]+1):
            for j in range(1,ar[1]+1):
                if sq(i,j):
                    sm=sm+lcm(i,j)
        print(sm%(2**30))
except:
    pass
#print((3**(1.0/2)).is_integer())

Submission status: Wrong Answer

Solution code:
import fractions
import functools

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

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


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

xalist = [int(x * 0.5) for x in alist]
amax = max(alist)

llcm = lcm(*xalist)
base_llcm = lcm_base(llcm, amax)

#print(llcm, base_llcm)
ans = (m-llcm) // base_llcm + 1
print(max(ans, 0))

Submission status: Wrong Answer

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

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

def mul(a,b):
    return a*b//euclid(a,b)

def lcm(S):
    
    return functools.reduce(mul,S)

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

Submission status: Wrong Answer

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