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:
from fractions import gcd
from math import ceil

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

def solve(N, M, A):
    num = lcm(A)
    if num > M:
        return 0
    else:
        return ceil(M / (num*2))
    

def main():
    N, M = map(int, input().split())
    A = list(set(int(x)//2 for x in input().split()))
    ans = solve(N, M, A)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
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] // gcd(ans, A[i])

lim = m // ans + 0.5
if lim < 1:
    print(0)
else:
    print(int((1 + lim /0.5) / 2))

Submission status: Wrong Answer

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

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)

x = A[0]
for i in range(1, N):
  x = lcm(x, A[i])
  if x // 2 > M:
    print(0)
    exit()
#print(x)

if x // 2 <= M:
  print((M - x // 2) // x + 1)
else:
  print(0)

Submission status: Wrong Answer

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

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

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

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

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)

if len(A[A%2==0])!=len(A):
    ans=0
else:
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)

    mm=1
    for x in A//2:
        mm=lcm(mm,x)

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

Submission status: Wrong Answer

Solution code:

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)
def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
for i in range(len(AA)):
    l = lcm(l, AA[i])
amari = l % 2
if amari == 1:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(nums):
  x = nums[0]
  for i in range(1, len(nums)):
    x = (x * nums[i]) // gcd(x, nums[i])
  return x
N, M = map(int, input().split())
a = list(set(map(int,input().split())))
flag = 0
for i in range(len(a)):
  a[i] = a[i] / 2
  if a[i] % 2 == 0:
    flag = 1
    break
if flag == 1:
  print(0)
else:
  A = lcm(a)
  print(int((M // A + 1) // 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

ans = alist[0]

for i in range(1, len(alist)):
    ans = ans * alist[i] // gcd(ans, alist[i])

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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


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

b = lcmm(A)
if b > m:
    print(0)
else:
    print(-(-(m//b)//2))

Submission status: Wrong Answer

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

N, M=map(int, input().split())
if N==1:
  a=int(input())
  c=a//2
  print((M/c-1)//2)
  exit()

a=list(map(int, input().split()))
b=[a[i]//2 for i in range(N)]

c=func(b[0], b[1])
for i in range(2, N):
  c=func(c, b[i])
  
print(max(int((M/c-1)//2+1), 0))

Submission status: Wrong Answer

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

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [0]*N
for i in range(N):
    B[i] = A[i]//2

import functools
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)
    
if lcm(B) > M:
    print(0)
elif lcm(B) == M:
    print(1)
else:
    print((M-lcm(B))//2//lcm(B)+1)

Submission status: Wrong Answer

Solution code:
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y ==0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z

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

n,m = map(int,input().split())
a = list(map(int,input().split()))
tmplcm = 1
for i in a:
    tmplcm = lcm(tmplcm,i)


m -= tmplcm//2
ans = m // tmplcm +1
print(max(ans,0))

Submission status: Wrong Answer

Solution code:
import fractions
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

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

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

n,m = LI()
a = LI()

for i in a:
    if i%2==1:
        print(0)
        exit()

lcm = lcm_list(a)
print((m//(lcm//2))-(m//lcm))

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
a = list(set(iln()))

l = a[0]
for i in range(1, len(a)):
    l = lcm(l, a[i])
l = l // 2
print(M//l - (M//(l*2)))

Submission status: Wrong Answer

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

#gcd, lcm
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)

lb = lcm(b)
la = lcm(a)
if lb <= m:
  ans = 1+(m-lb)//la
else:
  ans = 0
print(ans)

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

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

    # all odd?

    for i in range(N):
        if half[i] %2 == 0:
            print(0)
            return 
    

    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:
N, M = map(int, input().split())
a = list(map(lambda x: int(x) // 2 , input().split()))

a = list(set(a))

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

print(tmp)

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 = a[0]
for i in a[1:]:
  lcm_a = lcm_a * i // fractions.gcd(lcm_a,i)
  if lcm_a > m * 2:
    print(0)
    exit()
ans = (m - lcm_a // 2) // lcm_a + 1
print(ans)

Submission status: Wrong Answer

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

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

def lcmall(ls):
    n=len(ls)
    ansls=list()
    for i in range(n//2):
        ansls.append(lcm(ls[2*i], ls[2*i+1]))

    if n%2==1:
        ansls.append(ls[-1])

    if len(ansls)==1:
        return ansls[0]
    else:
        return lcmall(ansls)


n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [n//2 for n in a]

l = lcmall(b)

if l%2:
    print(m//l//2+m//l%2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil


def lcm(iterable):
    a = iterable[0]

    for b in iterable:
        a = a * b // gcd(a, b)

    return a


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

    lcm_b = lcm(B)

    # print(lcm_b)

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


if __name__ == '__main__':
    main()

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]
ki = 0; gu = 0
if (A[0]//2)%2 == 1:
    ki = 1
else:
    gu = 1
for i in range(1,N):
    if (A[i]//2)%2 == 1:
        ki = 1
    else:
        gu = 1
    if ki*gu == 1:
        print(0)
        exit()
    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:
from fractions import gcd

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

# bの最小公倍数を求める
L = b[0]
for i in range(1, len(b)):
    L = L * b[i] // gcd(L, b[i])

# (Lの倍数の個数) - (2Lの倍数の個数)と考える
print(M//L - M//(2*L))

Submission status: Wrong Answer

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

p = 1
sets = []
flag = True
a0 = an[0]
cal = a0 * (p + 0.5)
while cal < M:
  sets.append(cal)
  p = p + 1
  cal = a0 * (p + 0.5)
for a in an[1:]:
  nexts = []
  p = 1
  cal = a * (p+0.5)
  while cal < M:
    if cal in sets:
      nexts.append(cal)
    p = p + 1
    cal = a * (p+0.5)
  sets = nexts
  if len(sets) == 0:
    break

print(len(sets))

Submission status: Wrong Answer

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

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

if (m%lmc)<lmc//2:
    total+=(m//lmc)
else:
    total+=(m//lmc)+1

print(total)

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()))
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:
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))
    
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()))
a.sort()
b=[]
for num in a:
  b.append(num//2)
c=set(b)
import fractions
ans=b[0]
flag=True

for item in c:
  if item%2==0:
    print(0)
    flag=False
    break

if flag:
  for item in c:
    ans=ans*item // fractions.gcd(ans,item)
  print((M//ans+1)//2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
while True:
  if a[0] % 2 == 0:
    a[0] //= 2
    cnt += 1
  else:
    break
div = 2 ** cnt
for i in range(1,n):
  if a[i] % div == 0:
    a[i] //= div
    if a[i] % 2 == 0:
      print(0)
      break
  else:
    print(0)
    break
  if cnt == 0:
    print(0)
    break
else:
  #print(a)
  lcm = a[0]
  for i in range(1,n):
    big,sml = a[i],lcm
    while sml != 0:
      big,sml = sml,big%sml
    lcm *= a[i] // big
  #print(lcm)
  dbl = 2 * lcm
  ans = m // dbl
  m -= dbl * ans
  #print(dbl,ans,m)
  if m >= lcm:
    ans += 1
  print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import fractions
N, M = map(int, input().split())
A = tuple(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)


Ahalf = [a//2 for a in A]
lcmA = lcm_list(Ahalf)
#print(A)
#print(lcm_list(Ahalf))

n = int(M / lcmA + 1) // 2
print(n)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
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()))
A2=[]
for i in range(N):
    A2.append(A[i]//2)

l=lcm_list(A2)

ans=M//l
if ans%2==1:
    print(max(ans//2+1,0))
else:
    print(max(ans//2,0))

Submission status: Wrong Answer

Solution code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
n = len(a)
for i in range(n):
  a[i]//=2

gd = a[0]

for i in range(1,n):
  gd = fractions.gcd(gd, a[i])
  if (gd==1):
    break

sm = 1

for i in range(n):
  sm *= a[i]
  if (sm // gd > m):
    print(0)
    exit(0)

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

print(m+1)

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
for i in range(len(A)):
  A[i]//=2
  if A[i]%2==0:
    print(0)
    exit(0)
  L=lcd(L,A[i])
    
ans=M//(L*2)
ans+=(M%(L*2))//L
print(ans)

Submission status: Wrong Answer

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

LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


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]
c = [x % 2 == 0 for x in b]
d = [x % 2 == 1 for x in b]

if not any(c) and not all(d):
  print(0)
  exit()

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

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

n, m = map(int, input().split())
a_str_list = input().split()

a_list = []

for item in a_str_list:
    a_list.append(int(item))

step = lcm_list(a_list)
start = lcm_list(a_list) // 2

if m - start < 0:
    print(0)
else:
    print(((m-start) // step)+1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

while True:
    all_odd = True
    for i in range(len(a)):
        a[i]//=2
        if a[i]%2==0:
            all_odd = False
        if a[i]==0:
            print(0)
            sys.exit()
    if all_odd is True:
        break

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

print(m//_min-(m//_min)//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_base(x, y):
    return (x * y) // gcd(x, y)

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

n_lcm = lcm_list(a)
h_lcm = n_lcm // 2
print((m - h_lcm)//n_lcm + 1)

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

a = sorted(list(set(a)))

owa = 0
saiko = a[0]//2
che = (a[0]//2)%2
if che == 0 and len(a) != 1:
    owa = 1

for i in range(1,len(a)):
    if (a[i]//2)%2 == 0:
        owa = 1
        break
    t1 = a[i]//2
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe

if owa == 1:
    print(0)
else:
    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
import sys
input = sys.stdin.readline

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


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

baisu = A[0]

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:
# -*- 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()
    cnt = 0
    while(True):
        if a[0] % 2 == 0:
            cnt += 1
            a = list(map(lambda x: x // 2, a))
        else:
            break
    c = pow(2, cnt)
    for i in range(n):
        if a[i] % 2 == 0:
            print(0)
            exit()
    now = 1
    for i in range(n):
        now = lcm_base(now, a[i])
        if(now >= c * m):
            print(0)
            exit()
    la = now
    x = m // la
    print((x + 1) // c)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def p_d():
    from functools import reduce
    from fractions import gcd
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, 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)
    print((m // lcm + 1) // 2)
    
p_d()

Submission status: Wrong Answer

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

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(x,y):
    if y==0:return x
    t=(x,y)
    if t in memo:return memo[t]
    res=memo[t]=gcd(y,x%y)
    return res
memo={}

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

def main():
    n,m=MI()
    aa=LI()
    aa=set(aa)
    l=1
    for a in aa:
        if a%4==0:
            print(0)
            exit()
        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()))

import functools


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)


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

min = lcm(a)

#M = M // 2

Sum = 0

x = 1
while min * x <= M:
    #print(min*x,M)
    Sum += 1
    x += 2

print(Sum)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
from math import ceil


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


N, M = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
l = reduce(lcm, a)
ans = ceil((M // l) / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(x, y): 
  while(y): 
       x, y = y, x % y 
  return x 
n,m=map(int,input().split())
a=[int(_) for _ in input().split()]
od=int(0)
ev=int(0)
lc=int(a[0]//2)
for i in range(1,n):
	lc=(lc*(a[i]//2))//gcd(lc,(a[i])//2);
	if (a[i]//2)%2:
		od+=1
	else:
		ev+=1
if ev and od:
	print(0)
else:
	ans=(m-lc)//(2*lc);
	ans+=1
	print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
s = lcm_list(A)
#find the smallest value
m = max(A)
for i in range(s//m+1):
    flag = True
    x = i*m + m//2
    for e in A:
        if (x-e//2)%e == 0 and x>=e//2:
            pass
        else:
            flag = False
            break
    if flag:
        break
if x > M:
    print(0)
    exit()
else:
    print((M-x)//s+1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = sorted(set(map(lambda x: (int(x) // 2), input().split())), reverse=True)

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

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


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

cm_num = M // now
print(cm_num // 2 + int(cm_num % 2 == 1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

# bの最小公倍数を求める
L = b[0]
for i in range(1, N):
    L = L * b[i] // gcd(L, b[i])

"""
# 1, 2, ..., M の中で (L * 奇数) の形で表せるものの個数が答え
if (M // L) % 2 == 0:
    m = M // L - 1
else:
    m = M // L
print(m // 2 + 1)
"""

# L * 整数 の個数 - 2L * 整数 の個数と考える
print(M//L - M//(2*L))

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 = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
m -= m % all_lcm
if not m % 2:
  m -= all_lcm
print(m // all_lcm // 2 + 1)

Submission status: Wrong Answer

Solution code:
import fractions
import math


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 // 2) / num + 1)

print(ans)

Submission status: Wrong Answer

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

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

n, m = map(int, input().split())
a = [int(x)//2 for x in input().split()]
ma = max(a)
for x in a:
    ma = (ma-x + 2*x-1)//(2*x)*(2*x)+x
    if ma > m:
        print(0)
        exit(0)
lc = 1
for x in a:
    lc = lcm(lc, 2*x)
    if lc > m:
        print(0)
        exit(0)
ret = 1
m -= ma
ret += m//lc
print(ret)

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)

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])
while g % 2 == 0:
	g //= 2

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

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = 1
flag = 0
for i in range(N):
    gcd = fractions.gcd(A[i]//2, lcm_half)
    lcm_half = (lcm_half * (A[i]) // 2) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    ans = 1+M//(lcm_half*2)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter
    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]

    flag=0
    for i in a:
        if i%2==0:
            flag=1
    if flag==1:
        if len(Counter(a))==1:
            print((m//a[0]+1)//2)
            return
        else:
            print(0)
            return
    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 # version 3.4
from collections import defaultdict
from functools import reduce

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

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


def s_in():
    return input()

def n_in():
    return int(input())

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

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

N, M = l_in()
A = l_in()

B = [a//2 for a in A]
L = lcm(*B)

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

Submission status: Wrong Answer

Solution code:
'''input
3 100
14 22 40
'''
# A coding delight
from sys import stdin, stdout
import gc
from copy import deepcopy
from itertools import permutations
gc.disable()
input = stdin.readline
import math


def myfunc(num):
	return num//2

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

def find_lcm(num1, num2): 
    return (num1 * num2) // gcd(num1, num2)

def lcm(l):
	if len(l) == 1:
		return l[0]
	num1 = l[0] 
	num2 = l[1] 
	lcm = find_lcm(num1, num2) 
	  
	for i in range(2, len(l)): 
	    lcm = find_lcm(lcm, l[i])
	return lcm
# main starts
n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr = list(map(myfunc, arr))
num = lcm(arr)

# print(num)
if num > m:
	print(0)
else:
	k = m//num
	if k % 2 == 0:
		print(k//2)
	else:
		print(k//2 + 1)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
if not sum(e & 1 for e in a) in [0, n]:
    print(0)
    exit(0)
lcm = 1
for e in a:
    e //= 2
    lcm = min(m + 10, (lcm * e) // gcd(lcm, e))

res = (1 + m // lcm) // 2
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    return gcd(b % a, a)


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


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

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

l = 1
for e in A:
    l = lcd(l, e)

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

print(ans)