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:
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


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


N, M = map(int, input().split())
a = tuple(map(int, input().split()))
lcm_num = a[0]
lcm_half = a[0] // 2
for i in range(1, N):
    tmp = a[i]
    lcm_num = lcm(lcm_num, tmp)
    lcm_half = lcm(lcm_half, tmp // 2)
print((M - lcm_half) // lcm_num + 1)

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

Submission status: Wrong Answer

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

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

l = 1
for i in range(n):
    a[i] //= 2
    l = l * a[i] // gcd(l, a[i])
    if l > 1000000000:
        print(0)
        exit()


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
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 = (int(n) for n in input().split())
a_list = (int(n) for n in input().split())
a_set = set(a_list)
a_list_back = list(a_set)

lcm_number = lcm(a_list_back)
i = lcm_number // 2
counter = 0
if i > M:
  print(0)
  exit()
#while i <= M:
#  counter += 1
#  i += lcm_number
init_n = M - i
counter = init_n // lcm_number
print(counter)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
As = Bs = []
for a in set(input().split()):
    for x in range(1,M):
        V = int(float(a) * float(x+0.5))
        if V > M:
            break
        elif V in As:
            Bs.append(V)
            As = list(set(As) & set(Bs))
        else:
            As.append(V)
R = 0
for x in range(1,M):
    C = Bs.count(x)
    if C == N:
        R += 1
print(R)

Submission status: Wrong Answer

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

if  M < lcm :
    ans = 0
else:
    ans = (M - lcm) // (2 * lcm) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def extended_gcd(a, b):
    """returns gcd(a, b), s, r s.t. a * s + b * r == gcd(a, b)"""
    s, old_s = 0, 1
    r, old_r = b, a
    while r:
        q = old_r // r
        old_r, r = r, old_r - q * r
        old_s, s = s, old_s - q * s
    return old_r, old_s, (old_r - old_s * a) // b if b else 0


def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x


lcm = lambda a, b: a * b // gcd(a, b)


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

    x = 0
    p = 1

    for i in a:
        g, s, r = extended_gcd(p, i)
        if (((i // 2) % g) - (x % g)) % g:
            print(0)
            return
        x += ((i // 2) - x) // g * s * p
        p = lcm(p, i)

    x %= p

    if x < m:
        print((m - x) // p + 1)
    else:
        print(0)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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

    cnt = 0
    for m in range(M):
        cnt2 = 0
        for a in A:
            if m % a == a // 2:
                cnt2 += 1
            else:
                break
        if cnt2 == len(A):
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    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()
    l = a[0] >> 1
    for i in a[1:]:
        g = gcd(l,i >> 1)
        l = l*(i >> 1)//g
    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
n,m = map(int,input().split())
l = list(map(int,input().split()))

for i in range(n):
    l[i] //= 2
    if l[i] % 2 == 0:
        print(0)
        exit()

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



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

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


n,m=map(int,input().split())
A=list(map(int,input().split()))
A=[i//2 for i in A]
print(m//(lcm_list(A)*2)+1)

Submission status: Wrong Answer

Solution code:
import math
def main():

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

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

    a = 1
    max_count = 0
    b = 1
    for i in range(len(A)):
        d = A[i]
        count = 0
        while d % 2 == 0:
            d = d // 2
            count += 1
        b = gcd(a, d)
        max_count = max(max_count, count)

    c = 1
    for i in range(len(A)):
        c *= A[i] // b
    c *= pow(2, count)

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


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

Submission status: Wrong Answer

Solution code:
import math

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

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

flag4 = False
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
g = a[0]
for i in range(n):
	g = lcm(g, a[i])
if g % 4 == 0:
	flag4 = True
if flag4:
	while g % 4 == 0:
		g //= 2
else:
	while g % 2 == 0:
		g //= 2
rb = m // g
if flag4:
	if rb % 2 == 0:
		print(rb // 2)
	else:
		print(rb // 2 + 1)
else:
	if rb % 2 == 0:
		print(rb // 2)
	else:
		print(rb // 2 + 1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

for X in range(M) :
  cnt = 0
  for k in range(N) :
    if ((2*X-a[k])/(2*a[k])).is_integer() :
      cnt += 1
  if cnt == N :
    ans += 1
    
print (ans)

Submission status: Wrong Answer

Solution code:
import fractions as fr
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]//fr.gcd(ans,a[i])
print(int(m/ans)+1)

Submission status: Wrong Answer

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

max = m // li[0]

goal = 0
for p in range(1,max+1):
  x = li[0]*(p+0.5)
  cnt = 0
  for b in li:
    if ((x / b) - 0.5) % 1 == 0 and ((x / b) - 0.5) > 0:  
      cnt += 1
  if cnt == (len(li)):
    goal += 1
        
print(goal)

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


n,m = map(int, input().split())
a = set(map(int, input().split()))
x = lcm(a)
print((m-x//2)//x+1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
ans=1  
for i in range(n):
  ans = lcm(ans,A[i]//2)
if ans > m:
    print(0)
else:
    print((m//ans)//2+1)

Submission status: Wrong Answer

Solution code:
def lcm(x, y):
    a = x
    b = y

    if (a > b):
        tmp = a
        a = b
        b = tmp

    while (b % a != 0):
        tmp = b % a
        b = a
        a = tmp

    return ((x // a) * y)

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

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

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

lm = a[0]

for i in range (1, n):
    lm = lcm(lm, a[i])

for i in range(n):
    if (a[i] % 2 == 0):
        ok = 1

if (ok == 1):
    print(0)
else:
    if (m - lm > 0):
        ok = 1
        print(ok + ((m - lm) // (lm * 2)))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math
import fractions

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [int(int(i)/2) for i in input().split()]

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

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

    lcmnum=lcm_list(a)
    count = math.ceil((m//lcmnum)/2)

    print(count)

Submission status: Wrong Answer

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

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

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

L=1
oddcnt=0
for i in range(len(A)):
  A[i]//=2
  if A[i]%2==1:
    oddcnt+=1
  L=lcd(L,A[i])

if oddcnt!=0 and oddcnt!=N:
  print(0)
  exit(0)

ans=M//(L*2)
ans+=(M%(L*2))//L
print(ans)

Submission status: Wrong Answer

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

x = 0
for i in range(1, m+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 itertools
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)
tmp=lcm_list(A)
if M>=tmp:
    print((M-tmp//2)//tmp+1)
else:
  print(0)

Submission status: Wrong Answer

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

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

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

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

lcm = lcm_list(A)
least_lcm = lcm // 2
print(floor( (M - least_lcm) // lcm + 1))

Submission status: Wrong Answer

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

div = set()

for x in a:
    x //= 2
    xsq = int(x**0.5)
    for d in range(1, xsq+1):
        if x%d:
            continue
        div.add(d)
        div.add(x//d)
# print(div)

for x in div:
    M //= x

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

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
B = []
for i in range(len(A)):
    B.append((A[i]//2)%2)
B = list(set(B))
if len(B)==2:
    print(0)
else:
    a = A[0]
    for i in range(1,len(A)):
        a = gcd(a,A[i])
    b = a
    for x in A:
        b *= x//a
    k = (M-b//2)//b
    print(k+1)

Submission status: Wrong Answer

Solution code:
from itertools import permutations as perm
from functools import reduce 
from fractions import gcd
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2, input().split()))
if sum([i % 2 for i in a]) != len(a):
    print(0)
    exit()
g = reduce(gcd, a)
# print(g)
l = g
for i in a:
    l *= i // g
from math import ceil
print(ceil(m // l / 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from math import gcd

N, M = [int(i) for i in input().split()]
a = map(int, input().split())
lcm = 1
for n in a:
    lcm = (lcm*n)//gcd(lcm,n)
lcm //= 2
print(M//lcm - M//(lcm*2))

Submission status: Wrong Answer

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

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


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

flag = False

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

if(sum(B) == 0 or sum(B) == N):
    flag = True

if(flag):
    over = False
    a = A[0]
    i = 1
    while(a <= M and i < N):
        a = lcm(a, A[i])
        if(a > M):
            over = True
        i += 1
    if(over):
        print(0)
    else:
        ans = M // a
        if(ans * a + a//2 <= M):
            ans += 1
        print(ans)
else:
    print(0)

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)
#  print(ans)
  lcm=1
  for e in ls:
    lcm=Lcm(lcm,e)
    if lcm*c*2>M:
      ans=0
      break
  x=lcm*c//2
  y=M//x+1
  #print(x)
  if ans==0:
    print(0)
  else:
    print(max([y//2,0]))

Submission status: Wrong Answer

Solution code:
import fractions
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcd = a[0]
for i in range(1,n):
    gcd = gcd * a[i]*0.5//fractions.gcd(gcd,a[i])
#gcd*=0.5
gcda=gcd
fin = 0
ans = 0
print(math.ceil(m/gcd/2))

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()))
A.sort()

baisu = A[0]

for i in range(1, n):
    baisu = baisu * A[i] // gcd(baisu, A[i])

# for a in A:
    # baisu = lcm(baisu, a)
# print(baisu)

b = baisu // 2
c = m // b + 1
d = c // 2
print(d)

Submission status: Wrong Answer

Solution code:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(p,q):
    return p*q//gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
p = m//x
if p%2==0:
    ans = p//2
else:
    ans = p//2 +1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(num_list):
    x = num_list[0]
    for i in range(1, len(a)):
        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()))

f = 1
a_lcm = lcm(a)
semi_lcm_candidate = a_lcm * f
ans = 0

flag = True
for v in a:
    if (semi_lcm_candidate // v) % 2 == 0:
        flag = False
if flag:
    ans += 1
    ans += m // a_lcm

print(ans)

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])
print(int((int(M/ans)+1)/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(set(map(int, input().split())))
n = len(a)
a = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
  if all_lcm > m:
    exit(print(0))
if all_lcm % 2 == 0:
  exit(print(0))
m -= m % all_lcm
if m % 2 == 0:
  m -= all_lcm
print(m // all_lcm // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

from collections import Counter

N, M = map(int, input().split())
a = [int(i) for i in input().split()]
c = list(Counter(a).keys())

# 最大公約数
def gcd(a, b) :
    if b > a : 
        a, b = b, a
    
    while b != 0 :
        a, b = b, a % b
    return a

p = c[0]
g = c[0]
if len(c) >= 2 :
  for i in range(1, len(c)) :
    g = gcd(g, a[i])
    p *= a[i]

lcm = p // g

print(int(M / lcm + 0.5))

Submission status: Wrong Answer

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

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] // fractions.gcd(lcm, a[i])



ans=0
if M>=lcm//2:
    M-=lcm//2
    ans+=1
    ans+=M//(lcm)
    
print(ans)

Submission status: Wrong Answer

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

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

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

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

lcm = lcm_list(A)
least_lcm = lcm // 2
print(floor( (M - least_lcm) / lcm + 1))

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)


def resolve():
    n, m = map(int, input().split())
    a = list(set(map(int, input().split())))
    b = [x // 2 for x in a]
    s = b[0]
    for i in b[1:]:
        s = lcm(s, i)
    print(m // s - (m // (2 * s)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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


def akane(x):
    if 0.5 * g * c * x <= m:
        return True
    else:
        return False


n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = set(a)
g = a[0]

for i in b:
    g = gcd(g, i)

for i in b:
    if (i // g) % 2 == 0:
        print(0)
        exit()

c = a[0]
g = a[-1] // g

ok = 1
akan = 10 ** 10
while abs(ok - akan) > 1:
    mid = (ok + akan) // 2
    if akane(mid):
        ok = mid
    else:
        akan = mid
print(ok // 2 + 1)

Submission status: Wrong Answer

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

N,M = map(int,input().split())
A = set(int(i) for i in input().split())

MINX = reduce(lcm, A)
print(MINX)
if M//MINX == 0:
    print(0)
else:
    print(M//MINX + 1)

Submission status: Wrong Answer

Solution code:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def multiple(a, b):
    return a*b // gcd(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)

n, m = na()
a = na()

r = lcm(a)//2
b = m//r
print((b+1)//2)

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


n,m = map(int, input().split())
a = set(map(int, input().split()))
print(a)
x = lcm(a)
print((m-x//2)//x+1)

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

def lcmlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = lcm(a,l[i])
    return a

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Aup = list(set(A))
B = [Aup[i]//2 for i in range(len(Aup))]
X = lcmlist(B)

#print(Aup)
#print(B)
#print(X)

p = M//X
#print(p)
if p%2 == 0:
    ans = p//2
else:
    ans = p//2+1


print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

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

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

if common % 2 == 0:
  print(0)
else:
  print(ceil((M // common) / 2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def extended_gcd(a, b):
    """returns gcd(a, b), s, r s.t. a * s + b * r == gcd(a, b)"""
    s, old_s = 0, 1
    r, old_r = b, a
    while r:
        q = old_r // r
        old_r, r = r, old_r - q * r
        old_s, s = s, old_s - q * s
    return old_r, old_s, (old_r - old_s * a) // b if b else 0


def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x


lcm = lambda a, b: a * b // gcd(a, b)


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

    x = 0
    p = 1

    for i in a:
        g, s, r = extended_gcd(p, i)
        if (((i // 2) % g) - (x % g)) % g:
            print(0)
            return
        x += ((i // 2) - x) // g * s * p
        p = lcm(p, i)

    x %= p

    s = 0
    while x < m:
        s += 1
        x += p

    print(s)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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 > m:
            return -1
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)
if l>m or l==-1:
    print(0)
else:
    print( round(m/l) )

Submission status: Wrong Answer

Solution code:
def get_gcd(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]

'''
for b in A[1:]:
    B = get_lcm(B, b)
'''

print(int((M + 0.5 * B) // B))

Submission status: Wrong Answer

Solution code:
import itertools
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)
tmp=lcm_list(A)
if M>tmp:
    print((M-tmp//2)//tmp+1)
else:
  print(0)

Submission status: Wrong Answer

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

from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
p=1
for a in A:
  p=lcm(p,a//2)

print(M//(p*2)+1)

Submission status: Wrong Answer

Solution code:
import math

def gcd(a,b):
    if a<b:
        a,b=b,a
    while a%b!=0:
        a,b=b,a%b
    return b
def v(n,a):
    for i in a:
        if n%i==0:
            return False
    return True
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
b=[i//2 for i in a]
l=b[0]
for i in range(1,n):
    l=l*b[i]//gcd(l,b[i])
if l%2==0 or l>m:
    print(0)
else:
    p=m//l
    print(p//2+(p%2>0))

Submission status: Wrong Answer

Solution code:
import math
def main():

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

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

    a = 1
    max_count = 0
    for i in range(len(A)):
        d = A[i]
        count = 0
        while d % 2 == 0:
            d = d // 2
            count += 1
        b = gcd(a, d)
        max_count = max(max_count, count)
    c = 1
    for i in range(len(A)):
        c *= A[i] // b
    return (M // c + 1) // 2

Submission status: Wrong Answer

Solution code:
n, m = [ int(v) for v in input().split() ]
a_list = list(set([ int(v)//2 for v in input().split() ]))

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

n = len(a_list)
if n == 1:
    p = a_list[0]
    m -= p
    print(m//(p*2)+1)
    
else:
    if all([i % 2 == 1 for i in a_list]):
        p = 1
        for j in a_list:
            p = lcm(p, j)
        if p > m:
            print(0)
        else:
            m -= p
            print(m//(p*2)+1)

    else:
        print(0)

Submission status: Wrong Answer

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

import numpy as np
import fractions
A=np.array(A)

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

if len(A[(A//2)%2==1])!=len(A):
    ans=0
    
else:
    mm=1
    for x in A//2:
        mm=lcm(mm,x)

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