Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
n,m=map(int,(input().split()))
A=set(map(int,input().split()))
A=list(A)
nagasa=len(A)
H=[0]*nagasa
def gcd(a, b):
    if b>a:
        return gcd(b,a)
    else:
        if b==0:
            return a
        else:
            return gcd(b,a%b)        
G=A[0]//2
kake=1
for i in range(nagasa):
    H[i]=A[i]//2
    kake*=H[i]
    G=gcd(G, H[i])
L=kake//(G**(nagasa-1))
kazu=m//L
print(kazu//2 if kazu%2==0 else (kazu+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
def lcm_(x, y):
    return x * y // gcd(x, y)
a = reduce(lcm_, map(lambda x: x//2, A))
print(M//a - M//(2*a))

Submission status: Wrong Answer

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

n,m=map(int,input().split())
a=list(map(int,input().split()))
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 (m//L)%2==0:
  print((m//L)//2)
else:
  print(((m//L)//2)+1)

Submission status: Wrong Answer

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

def div2(n):
    count=0
    while n%2==1:
        count+=1
        n//=2
    return count

def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

b = [div2(a[i]) for i in range(N)]

flag = True

for i in range(1,N):
    if b[i]!=b[0]:
        flag=False
        break

if flag:
    l = a[0]//2
    for i in range(1,N):
        l = (l*a[i]//2)//gcd(l,a[i]//2)
    #print(l)
    print((M-l)//(2*l) + 1)
else:
    print(0)

Submission status: Wrong Answer

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

Asp = []
for a in As:
    Asp.append(a // 2)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


import functools

l = functools.reduce(lcm, Asp)

print(M // l - M // (2 * l))

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
from fractions import gcd

n,m = map(int,readline().split())
alst = list(map(int,readline().split()))

mm = 2 * m
if n == 1:
  g = alst[0]
else:
  g = alst[0]*alst[1]//gcd(alst[0],alst[1])
  for i in alst[2:]:
    g = g*i//gcd(g, i)
if g > mm:
  print(0)
else:
  c = mm // g
  c = c//2+c%2
  print(c)

Submission status: Wrong Answer

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

def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

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

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

Submission status: Wrong Answer

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

b = []
for i in a:
    b.append(i // 2)
bs = list(set(b))
kake = 1
for i in bs:
    kake *= i
baisu = m // kake

print(-(-baisu // 2))

Submission status: Wrong Answer

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

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

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
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]//2
ll=a[0]
for i in range(1,n):
  l=lcm(l,a[i]//2)
  ll=lcm(ll,a[i])
  if l>m:print(0);exit()
m=max(m-l,0)
print(m//ll+1)

Submission status: Wrong Answer

Solution code:
def main():
    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(n-1):
        g=(g*a[i+1])//gcd(g,a[i+1])

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

main()

Submission status: Wrong Answer

Solution code:
import fractions
import sys

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


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

all_lcm = 1

for a in l:
    all_lcm = lcm(a, all_lcm)

minimum = None
for b in range(1, M):
    minimum = b
    for a in l:
        if (b - a/2) % a != 0:
            minimum = None
            break

    if minimum is not None:
        break

if minimum is None:
    print(0)
    sys.exit()

print(1 + int((M - minimum) / all_lcm))

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) // 2 for i in sys.stdin.readline().split()]

def gcd(a, b):
    while a and b:
        if a < b:
            b %= a
        else:
            a %= b
    return max(a, b)

def scm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

flg = True
res = a_ls[0]
for a in a_ls[1:]:
    res = scm(res, a)
    if res > m:
        flg = False
        break

if flg:
    #print(ceil(m // res / 2))
    print((m - res) // (res * 2) + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
#s = [int(input()) for i in range(3)]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

a = list(map(int,input().split()))
a2 = [int(i//2) for i in a]
flag = False
for i in a2:
    if i%2 == 0:
        flag = True
if flag:
    print(0)
else:
    if N == 1:
        div = M//a2[0]
        print((div+1)//2)
    else:
        gcda = a2[0]*a2[1]//gcd(a2[0],a2[1])
        for i in range(2,N):
            gcda = gcda*a2[i]//gcd(gcda,a2[i])
        div = M//gcda
        print((div+1)//2)

Submission status: Wrong Answer

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

import numpy as np

import bisect
import re
import heapq


from copy import deepcopy
import itertools


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




from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,m = mi()
    a = li()
    for i in range(n):
        a[i] //= 2

    k = 1
    for i in range(n):
        k = lcm(a[i],k)
        if m < k:
            print(0)
            exit()
    #print(k)
    anstmp = m//k
    print(anstmp//2+anstmp%2)

    
main()

Submission status: Wrong Answer

Solution code:
import fractions

N,M = map(int, input().split())
A = [int(a) for a in input().split()]

for i in range(N):
    A[i] //= 2
    
num = 1
for i in range(N):
    num = num*A[i]//fractions.gcd(num, A[i])
    
f = 0
for i in range(N):
    if (num//A[i])%2 == 0:
        f = 1
        break
        
if f == 0:
    print((M-num)//num//2+min(M//num, 1))
else:
    print(0)

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()))
g = a[0]
for x in a:
    g = lcm(g, x)
    if g > m:
        break
t = m // g
for i, x in enumerate(a):
    if x % 2:
        print(0)
        exit(0)
    a[i] //= 2
g = a[0]
for x in a:
    g = lcm(g, x)
    if g > m:
        break
ans = m // g
print(ans - t)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=list(map(int,input().split()))
    g=a[0]
    for x in a[1:]:
        g=g*x//gcd(g,x)
    print((M+(g//2))//g)

        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import functools

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


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


all_lcm = functools.reduce(lcm, a)
ans = -((-(M*2 // all_lcm)) // 2)

print(ans)

Submission status: Wrong Answer

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

bn = [a // 2 for a in an]

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)

l = lcm(bn)
print(m // l - m // (2*l))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
A=a[0]
for i in range(n-1):
	A=A*a[i+1]//gcd(A,a[i+1])
m+=A//2
ans=m//A
print(ans)

Submission status: Wrong Answer

Solution code:
def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b

def calc_lcm(a, b):
	gcm = calc_gcm(a, b)
	return a * b // gcm

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

lcm = 1
for a in a_list:
	lcm = calc_lcm(lcm, a)

def check():
	for a in a_list:
		if (lcm // a) % 2 == 0:
			return False
	return True

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

Submission status: Wrong Answer

Solution code:
from math import floor
N,M = map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
A = list(map(int,input().split()))
for i in range(N):
    A[i] //= 2
l = A[0]
for i in range(1,N):
    l = (l*A[i])//gcd(l,A[i])
print(floor((M/l+1)/2))

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
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]//2
ll=a[0]
for i in range(1,n):
  l=lcm(l,a[i]//2)
  ll=lcm(ll,a[i])
  if l>m:print(0);exit()
n=max(n-l,0)
m=max(m-l,0)
print(m//ll-n//ll+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

import sys
input = sys.stdin.readline

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



g = 1
for a in A:
    a //= 2
    l = gcd(g, a)
    g = g*a//l

ans = (M+g)//(2*g)
print(ans)

Submission status: Wrong Answer

Solution code:
LOCAL = False


def dprint(*args):
  if LOCAL:
    print(*args)


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

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

# pro = 1
# for x in b:
#   pro *= x

# import fractions
# gcd = 0
# for x in b:
#   gcd = fractions.gcd(gcd, x)
# dprint('gcd','=',gcd)

# lcm = pro // gcd

# https://note.nkmk.me/python-gcd-lcm/

import math
from functools import reduce
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)


lcm = lcm_list(b)

dprint('lcm', '=', lcm)

import math
print(math.ceil(m // lcm / 2))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

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

def div_ceil(x, y): return (x + y - 1) // y

N, M = map(int, input().split())
*A, = map(int, input().split())
temp = [a // 2 for a in A]
A = list(set(temp))
L = list(accumulate(A, lcm))[-1]
ans = 0 if L % 2 == 0 else div_ceil(M, L) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def gcd(a, b):
  while a and b:
    if a < b:
      b %= a
    else:
      a %= b
  return max(a, b)
 
def scm(a, b):
  _gcd = gcd(a, b)
  return a * b // _gcd

def main():
  n,m=LI()
  l=LI()

  m*=2

  k=l[0]
  for x in l[1:]:
    k=scm(k,x)

  return -(-m//k)//2

# main()
print(main())

Submission status: Wrong Answer

Solution code:
from fractions import *

N, M = map(int, raw_input().split())
a = map(int, raw_input().split())

g = a[0]/2
for i in range(1, N):
  g = g*(a[i]/2)/(gcd(g, a[i]/2))
  if g>10**9:
    print 0
    exit(0)
print (M+g)/(2*g)

Submission status: Wrong Answer

Solution code:
import fractions, math
from functools import reduce

N, M = map(int, input().split())
A = [int(i/2) for i in list(map(int, 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)

print((M - lcm_list(A)) // (2*lcm_list(A)) + 1 )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
from fractions import gcd
from functools import reduce
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template

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

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

def main():
    n, m = mi()
    a = lmi()
    a = list(map(lambda x: x // 2, a))
    now = 1
    for i in range(n):
        now = lcm_base(now, a[i])
        if(now >= 2 * m):
            print(0)
            exit()
    la = now
    x = m // la
    print(-(-x // 2))
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def d_semi_common_multiple():
    from fractions import gcd
    from functools import reduce
    N, M = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    lcm = reduce(lambda x, y: x * y // gcd(x, y), A)
    return 2 * M // lcm - M // lcm

print(d_semi_common_multiple())

Submission status: Wrong Answer

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

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

L=a[0]
for i in range(1,n):
  L=lcm(L,a[i])
print((m+L//2)//L)

Submission status: Wrong Answer

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


def solve(N: int, M: int, a: "List[int]"):
    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)

    lcm = lcm_list(a)

    print((M-lcm//2)//lcm + 1)
    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:
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)


def solve():
    N, M, *a = map(int, open(0).read().split())
    
    a_lcm = lcm_list(a)
    ans = 1 + (M - a_lcm // 2) // a_lcm
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def gcd(a,b):
    while b:a,b=b,a%b
    return a

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

def main():
    n,m=MI()
    aa=LI()
    l=1
    for a in aa:
        l=lcm(l,a//2)
    print((m//l+1)//2)

main()

Submission status: Wrong Answer

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

from fractions import gcd
f = True
l = 1
for i in range(n):
    b = a[i] // 2
    l = l * b // gcd(l, b)

    if l > m:
        f = False
        break

if not f:
    print(0)
else:
    mmax = (m - l) // (2 * l)
    print(mmax + 1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import fractions


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = 1
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            ans = (ans * a // 2) // fractions.gcd(ans, a // 2)

    print(-(-(M // ans) // 2))


    
    
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

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

k=1

for a in A:
    k=lcm(k,a//2)

print(max(0,(M-k)//(2*k)+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()))

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:
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()))
flag = True
for i in range(n):
    if a[i] % 2 == 1:
        flag = False
ans = 0

if flag:
    for i in range(n):
        a[i] /= 2
    tmp = int(lcm_list(a))
    ans = (m-tmp) // (2*tmp) + 1
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import functools
N,M = map(int,input().split())
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def gcd(nums):
    return functools.reduce(euclid, nums)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)

num = list(map(int, input().split()))
ans = M//(lcm(num)//2)
print((ans+1)//2)

Submission status: Wrong Answer

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


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


N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [a//2 for a in A]

base = 1
for b in B:
  if base % b == 0:
    continue
  
  base = lcm(base, b)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [i//2 for i in a]
lcm = a[0]
for i in range(n-1):
  lcm =a[i+1]*lcm//gcd(a[i+1],lcm)
print((m//lcm+1)//2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m, *a = map(int, open(0).read().split())
lcm = 1
for x in a:
	x //= 2
	lcm = lcm * x // gcd(lcm, x)
print(m // (2 * lcm) + (m % (2 * lcm) >= lcm))

Submission status: Wrong Answer

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

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

num = ans //2
print(M//num-M//ans)

Submission status: Wrong Answer

Solution code:
import fractions
def Lcm(X,Y):
  return X*Y//fractions.gcd(X,Y)
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
c=1
ans=1
while ls[0]%2==0:
  ls[0]//=2
  c*=2
if c==1:
  ans=0
else:
  #print(c)
  for i in range(1,N):
    if ls[i]%c!=0:
      ans=0
      break
    elif ls[i]%(2*c)==0:
      ans=0
      break
    else:
      ls[i]//=c
  #print(ls)
  lcm=1
  for e in ls:
    lcm=Lcm(lcm,e)
  x=lcm*c//2
  y=M//x+1
  #print(x)
  print(max([y//2,0]))

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()))
lcm_a = lcm(a)
ans = (m - lcm_a // 2) // lcm_a + 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
a = inpl()
ggg = 1
for i in range(n):
    ggg = ggg*a[i]//fractions.gcd(ggg,a[i])
# print(ggg)
if(ggg//2) % 2:
    print((m-ggg//2)//ggg+1)
else:
    print(m*2//ggg)

Submission status: Wrong Answer

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

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])
if ans//2 > m:
  print(0)
else:
  print(((m-ans//2)//ans)+1)

Submission status: Wrong Answer

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

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

from math import ceil

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

common = 1
for i in range(N):
  A[i] //= 2
  common = lcm(common, A[i])

print(ceil((M // common) / 2))

Submission status: Wrong Answer

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

import numpy as np

import bisect
import re
import heapq


from copy import deepcopy
import itertools


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




from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,m = mi()
    a = li()
    k = 1
    for i in range(n):
        k = lcm(a[i],k)
        if 2*m < k:
            print(0)
            exit()
    anstmp = (2*m)//k
    print(anstmp//2+anstmp%2)

    
main()

Submission status: Wrong Answer

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

def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

mul=A[0]
for i in range(1,n):
  mul=mul*A[i]//gcd(mul,A[i])
if mul%2==0:
  print(0)
else:
  print(m//mul-m//(mul*2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd


def solve(n, m, aaa):
    lcm = 1
    for a in aaa:
        a //= 2
        lcm *= a // gcd(lcm, a)
        if lcm > m:
            return 0
    return (m // lcm + 1) // 2


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

print(solve(n, m, aaa))

Submission status: Wrong Answer

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

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

saiko = a[0]//2
for i in range(1,n):
    t1 = a[i]//2
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe


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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda a: a//2, A))
f = lambda x, y: x * y // gcd(x, y)
a = reduce(f, AA)
print(len(range(a, M+1, a*2)))

Submission status: Wrong Answer

Solution code:
N,M = list(map(int, input().split()))
a = list(map(int, input().split()))
C=0
for i in range(0,M):
  c=1
  for j in range(0,N):
    if i % a[j] != a[j]/2:
      c=0
  C=C+c
print(C)

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

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [i//2 for i in a]
g = lcm_list(b)
if any((g//i)%2==0 for i in a):
    ans = 0
else:
    ans = (m//g+1)//2
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]=a[i]//2
f2=1
for i in range(n):
    f=fractions.gcd(f2,a[i])
    f2=a[i]*f2//f
#print(f2)
ans=m//f2
print((ans+1)//2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for i in range(N):
    g=g*A[i]//gcd(g,A[i])
print(M//(g//2)-M//g if M%2==0 else 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,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
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 NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
import fractions
gcd=fractions.gcd
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,m=LI()
a=LI()
b=[i//2 for i in a]
lcm=b[0]
for i in range(1,n):
    lcm=b[i]*lcm//gcd(b[i],lcm)

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

print(ans)

Submission status: Wrong Answer

Solution code:
def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


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


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

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])

# print(m, a_lcm)
ans = ((m // a_lcm) + 1) // 2
print(ans)

Submission status: Wrong Answer

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

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return y

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

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = lcm(b,A[i])
    # print(b)

    ans = m//(b*2)
    if (m//(b*2))*(b*2)+b<=m:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X = MI()
    A=LI()
    lcm = 1
    for a in A:
        a//=2
        if lcm > X:
            print(0)
            return
        lcm = lcm//gcd(a,lcm)*a
    print(ceil(X//lcm/2))
if __name__ == '__main__':
    main()