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

import fractions

lcm = a[0]//2

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

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

Submission status: Wrong Answer

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

import fractions

lcm = a[0]//2

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


print(M//lcm//2)

Submission status: Wrong Answer

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

import fractions

lcm = a[0]//2

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

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

Submission status: Wrong Answer

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

e = 0
for ai in a:
    ei = 0
    while ai % 2 == 0:
        ei += 1
        ai //= 2
    e = min(e, ei)

m //= 2 ** e
a = [ai // 2 ** e for ai in a]

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

lcm = 1
for ai in a:
    d = gcd(lcm, ai)
    lcm = lcm * ai // d
    if lcm > m:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from math import ceil

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

e = 0
for ai in a:
    ei = 0
    while ai % 2 == 0:
        ei += 1
        ai //= 2
    e = min(e, ei)

m //= 2 ** e
a = [ai // 2 ** e for ai in a]

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

lcm = 1
for ai in a:
    d = gcd(lcm, ai)
    lcm = lcm * ai // d
    if lcm > m:
        print(0)
        exit()

print(ceil(m / lcm / 2))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

e = 0
for ai in a:
    ei = 0
    while ai % 2 == 0:
        ei += 1
        ai //= 2
    e = min(e, ei)

m //= 2 ** e
a = [ai // 2 ** e for ai in a]

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

lcm = 1
for ai in a:
    d = gcd(lcm, ai)
    lcm = lcm * ai // d
    if lcm > m:
        print(0)
        exit()

print(ceil(m // lcm // 2) + 1)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

print(int((M/semi_lcm-1)/2)+1)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

ans = M//lcm
ans = ans//2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

def lcm(p, q):
    result = p * q // gcd(p, q)
    return result

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

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

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
from functools import reduce
x=reduce(lambda x,y:x*y//gcd(x,y),A)
print((M+x//2)//x if all([a//2%2 for a in A]) else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import fractions
from functools import reduce

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

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

l=lcm_list(a)

for s,t in enumerate(a):
    if l%t==0:
      print("0")
      exit()

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

Submission status: Wrong Answer

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

import fractions
from functools import reduce

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

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

l=lcm_list(a)

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

Submission status: Wrong Answer

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

import fractions
from functools import reduce

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

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

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

l=lcm_list(a)

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

Submission status: Wrong Answer

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

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


def lcm(x, y):
    v = (x * y) // fractions.gcd(x, y)
    if v > M:
        print(0)
        exit()
    else:
        return v


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


a = list(map(int, input().split()))
a = list(map(lambda x: int(x / 2), a))
base = lcm_list(a)
if (base / a[0]) % 2 == 0:
    print(0)
else:
    print(ceil((M // base) / 2))

Submission status: Wrong Answer

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


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


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


if __name__ == '__main__':

    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(map(lambda x: int(x / 2), a))
    base = lcm_list(a)
    if (base % a[0]) % 2 == 0:
        print(0)
    else:
        print(ceil((M // base) / 2))

Submission status: Wrong Answer

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


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


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


if __name__ == '__main__':

    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(map(lambda x: int(x / 2), a))
    base = lcm_list(a)
    print(ceil((M // base) / 2))

Submission status: Wrong Answer

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

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

bound = int(M / a[0])
base = 0
for factor in range(bound):
    for i in range(1, N):
        if (a[0] * factor) % a[i]:
            break
        elif i == N-1:
            base = a[0] * factor
            break

    if base != 0:
        break

if base != 0:
    print(math.ceil((M // base) / 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

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

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

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

kizami = lcm_list(a)

a_hf = []

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

first = lcm_list(a_hf)

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

Submission status: Wrong Answer

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

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

lcm = 1
for i, ai in enumerate(a):
    gcd = mygcd(lcm, ai)
    lcm = (lcm * ai) // gcd

# print("#", lcm)

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

Submission status: Wrong Answer

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

N, M, *a_n = map(int, open(0).read().split())
a_n = list(set(a_n))
a_n = [a // 2 for a in a_n]
N = len(a_n)

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

def lcm_list(a_n):
    return reduce(lcm_base, a_n)

a_n_half = [0] * N
a_n_copy = copy.copy(a_n)
for i in range(N):
    while a_n_copy[i] % 2 == 0:
        a_n_copy[i] //= 2
        a_n_half[i] += 1
        
for i in range(N-1):
    if a_n_half[i] != a_n_half[i+1]:
        print(0)
        sys.exit()
        
print(-(-M // lcm_list(a_n) // 2))

Submission status: Wrong Answer

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

N, M, *a_n = map(int, open(0).read().split())
a_n = list(set(a_n))
a_n = [a // 2 for a in a_n]
N = len(a_n)

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

def lcm_list(a_n):
    return reduce(lcm_base, a_n)

a_n_half = [0] * N
a_n_copy = copy.copy(a_n)
for i in range(N):
    while a_n_copy[i] % 2 == 0:
        a_n_copy[i] //= 2
        a_n_half[i] += 1
        
for i in range(N-1):
    if a_n_half[i] != a_n_half[i+1]:
        print(0)
        sys.exit()
        
    
print(-(-M // lcm_list(a_n)) // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

N, M, *a_n = map(int, open(0).read().split())
a_n = list(set(a_n))
a_n = [a // 2 for a in a_n]
N = len(a_n)

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

def lcm_list(a_n):
    return reduce(lcm_base, a_n, 1)
    
print(-(-M // lcm_list(a_n)) // 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 main():
    n, m, *a_n = map(int, open(0).read().split())
    a_n_half = list(map(lambda x: x // 2, a_n))
    a_n_lcm = lcm(a_n_half)
    
    cnt = 0
    for i in range(a_n_lcm, m + 1, a_n_lcm * 2):
        cnt += 1
    print(cnt)
        
    
if __name__ == "__main__":
    main()

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 main():
    n, m, *a_n = map(int, open(0).read().split())
    a_n_half = list(map(lambda x: x // 2, a_n))
    a_n_lcm = lcm(a_n_half)
    
    cnt = m // a_n_lcm
    
    if cnt % 2 == 0:
        print(cnt // 2)
    else:
        print(cnt // 2 + 1)
        
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for x in range(1, m+1):
  for i in range(n):
    if x % A[i] == A[i]/2:
      continue
  else:
    X.append(x)
print(len(X))

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

"""""""""""""""""""""""""""""""""
 最大公約数 O()
"""""""""""""""""""""""""""""""""
# fractions.gcd(a,b)
def gcd(a, b):
    return fractions.gcd(a, b)

"""""""""""""""""""""""""""""""""
 最小公倍数 O()
"""""""""""""""""""""""""""""""""
def lcm(a,b):
    return (a*b) // fractions.gcd(a,b)


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


twice = 1
while True:
    if A[0] % (twice*2) == 0:
        twice*=2
    else:
        break

for a in A:
    if a%twice != 0:
        print(0)
        sys.exit()
    elif a%(twice*2) == 0:
        print(0)
        sys.exit()


half = 1 # 最小公倍数の二分の一
for i in range(N):
    A[i] /= 2
    half = lcm(half, A[i])

ans = (M//half) // 2 + int((M//half)%2 == 1)
print(int(ans))





"""
ATTENTION: Pythonで間に合うか？？

            <目安>
 文字列結合、再帰関数を含む→Python
 上を含まず時間が不安→PyPy3

"""

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

"""""""""""""""""""""""""""""""""
 最大公約数 O()
"""""""""""""""""""""""""""""""""
# fractions.gcd(a,b)
def gcd(a, b):
    return fractions.gcd(a, b)

"""""""""""""""""""""""""""""""""
 最小公倍数 O()
"""""""""""""""""""""""""""""""""
def lcm(a,b):
    return (a*b) // fractions.gcd(a,b)


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


twice = 1
while True:
    if A[0] % (twice*2) == 0:
        twice*=2
    else:
        break

for a in A:
    if a%twice != 0:
        print(0)
        sys.exit()
    elif a%(twice*2) == 0:
        print(0)
        sys.exit()

               

koubais = [] # 隣り合った２つの最小公倍数のリスト
for i in range(0, N, 2):
    if i == N-1:
        koubais.append(A[i]//2)
        break

    A[i] /= 2
    A[i+1] /= 2
    koubais.append(lcm(A[i+1], A[i]))

half = 1
for i in range(len(koubais)):
    half = lcm(half, koubais[i])

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

"""""""""""""""""""""""""""""""""
 最大公約数 O()
"""""""""""""""""""""""""""""""""
# fractions.gcd(a,b)
def gcd(a, b):
    return fractions.gcd(a, b)

"""""""""""""""""""""""""""""""""
 最小公倍数 O()
"""""""""""""""""""""""""""""""""
def lcm(a,b):
    return (a*b) // fractions.gcd(a,b)


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


twice = 1
while True:
    if A[0] % (twice*2) == 0:
        twice*=2
    else:
        break

for a in A:
    if a%twice != 0:
        print(0)
        sys.exit()
    elif a%(twice*2) == 0:
        print(0)
        sys.exit()

               

koubais = [] # 隣り合った２つの最小公倍数のリスト
for i in range(0, N, 2):
    if i == N-1:
        koubais.append(A[i]//2)
        break

    A[i] /= 2
    A[i+1] /= 2
    koubais.append(lcm(A[i+1], A[i]))

half = 1
for i in range(len(koubais)):
    half = lcm(half, koubais[i])

ans = (M//half) // 2 + int((M//half)%2 == 1)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

"""""""""""""""""""""""""""""""""
 最大公約数 O()
"""""""""""""""""""""""""""""""""
# fractions.gcd(a,b)
def gcd(a, b):
    return fractions.gcd(a, b)

"""""""""""""""""""""""""""""""""
 最小公倍数 O()
"""""""""""""""""""""""""""""""""
def lcm(a,b):
    return (a*b) // fractions.gcd(a,b)


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


half = 1 # 最小公倍数の二分の一
for i in range(N):
    A[i] /= 2
    half = lcm(half, A[i])

ans = (M//half) // 2 + int((M//half)%2 == 1)
print(int(ans))





"""
ATTENTION: Pythonで間に合うか？？

            <目安>
 文字列結合、再帰関数を含む→Python
 上を含まず時間が不安→PyPy3

"""

Submission status: Wrong Answer

Solution code:
#D
from fractions import gcd

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

ans = 0
#if some element in a is odd, it cannot be divided by 2
for v in a:
    if v%2 != 0:
        break
else:
    a = [i//2 for i in a]
    #if some element in a is even, any gcd cannot be odd
    for v in a:
        if v%2==0:
            break
    else:
        #calculate its lcm by using gcd
        lcm = 1
        for v in a:
            lcm = (lcm * v)//gcd(lcm, v)
        
        q = m //lcm
        ans = (q+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
# D
from fractions import gcd
import numpy as np
import sys
input = sys.stdin.readline

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

lcm = 1
for s in a:
    s//=2
    lcm = s*lcm//gcd(lcm, s)

ans=int( (int(M/lcm)+1)/2)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
    b_ = i//2
    b.append(b_)
count = 0
flag = True
res = a[0]

while res % 2 != 0:
    res = a[0]/2
    count += 1
for i in a:
    if i % 2**count != 0:
        flag = False
        break
if flag:    
    lcm = b[0]
    for i in range(1, len(b)):
        lcm = lcm*b[i]//fractions.gcd(lcm,b[i])
    ans = m // lcm - (m//(lcm*2))
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
    b_ = i//2
    b.append(b_)
count = 0
res = 0

for i in b:
    count += i%2
if count == 0 or count == len(a):    
    lcm = b[0]
    for i in range(1, len(b)):
        lcm = lcm*b[i]//fractions.gcd(lcm,b[i])
    ans = m // lcm - (m//(lcm*2))
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a.sort(reverse=True)
a_max = max(a)
a_min = min(a)
hansuu_max = M//a_min
hansuu = [i+0.5 for i in range(hansuu_max)]

hankoubaisuu_kari = {}
for i in hansuu:
    if a_max*i <= M:
        hankoubaisuu_kari[a_max*i] = 1

for i in range(1, len(a)):
    for k in hankoubaisuu_kari.keys():
        amari = (k / a[i]) * 10
        amari2 = amari % 10
        if amari2 == 5:
            hankoubaisuu_kari[k] += 1

count = 0
for v in hankoubaisuu_kari.values():
    if v == len(a):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math
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)

def solve(N: int, M: int, a: "List[int]"):
    a = [aa // 2 for aa in a]
    mm = lcm_list(a)
    print((M // mm + 1) // 2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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


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


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


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

if len(set(map(count, A))) == 1:
    T = lcm(A)
    ans = M // T + 1

print(ans)

Submission status: Wrong Answer

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

import fractions

ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
if ans > M*2:   
    print(0)
else:
    print(int(M/ans)+1)

Submission status: Wrong Answer

Solution code:
import itertools
import functools

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

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

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

    return a

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


x = functools.reduce(lcm, A, 1)

if x % 2  == 0:
    print(0)
else:
    print(M // x - M // (2 * x))

Submission status: Wrong Answer

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

B=set(A)
base=[]
count=0
answer=0

for i in range(1,M+1):
    if i>=(max(B)*1.5):
        if (i/(max(B))-0.5)%1==0:
            base.append(i)
for item in base:
    count=0
    for j in range(len(B)):
        if item>=(A[j]*1.5):
            if ((item/A[j])-0.5)%1==0:
                count+=1
                if count==N:
                    answer+=1
                    break
print(answer)

Submission status: Wrong Answer

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

ans = {}
max_p = round(M / min(list_a))

for i in list_a :
    hanko = {int(i*(x+0.5)) for x in range(max_p)}
    if ans == {} :
        ans = hanko
    else :
        ans = ans & hanko

print(len(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
lsm = 1
isOdd = True
for a in A:
  a //= 2
  if a%2 == 0: isOdd = False 
  lsm *= a // gcd(lsm, a)
print(M//lsm - M//(2*lsm)*isOdd)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
lsm = 1
for a in A:
  a //= 2
  lsm *= a // gcd(lsm, a)
print(M//lsm - M//(2*lsm))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N,M = [int(i) for i in input().rstrip().split()]
A = [int(i)//2 for i in input().rstrip().split()]

L = 1
for a in A:
    L = (L*a)//gcd(L,a)
print((M+L)//(2*L))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [ int(a) // 2 for a in input().split()]
from math import ceil
from fractions import gcd
def main():
    x = 1
    for a in A:
        if a%2 == 0:
            print(0)
            return
        if x%a != 0:
            x *= a // gcd(a,x)
    print(ceil((M // x)/2))
    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [ int(a) // 2 for a in input().split()]
from math import ceil
from fractions import gcd
def main():
    x = 1
    for a in A:
        if x%a != 0:
            x *= a // gcd(a,x)
    print(ceil((M // x)/2))
    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
from fractions import gcd
n,m = map(int,input().split())
a = np.array(input().split(),dtype=int)
a /= 2

def t_per2(k):
    num = 0
    while k%2 == 0:
        k = k//2
        num += 1
    return num

f = False
dcm = a[0]
t_2 = t_per2(a[0])
for i in a:
    dcm = (dcm*i)//gcd(dcm,i)
'''
    if dcm > m or not t_per2(i) == t_2:
        f = True
        break
'''

count = 0
if not f:
    count = math.ceil(int(m/dcm)/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):
    while b != 0:
        a, b, = b, a % b
    return a

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

b = [n//2 for n in a]
b = list(set(b))

c = b[0]
for i in range(1, len(b)):
    c = lcm(c, b[i])

ans = m // c

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
from fractions import gcd
n,m = map(int,input().split())
a = np.array(input().split(),dtype=int)

def t_per2(k):
    num = 0
    while k%2 == 0:
        k = k//2
        num += 1
    return num

f = False
dcm = a[0]
t_2 = t_per2(a[0])
for i in a:
    dcm = (dcm*i)//gcd(dcm,i)
    if dcm > m or not t_per2(i) == t_2:
        f = True
        break

count = 0
if not f:
    dcm = dcm//2
    count = math.ceil(int(m/dcm)/2)

print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

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

lcma=lcm(a)
temp=m//lcma
print(temp//2 if temp%2==0 else temp//2+1)

Submission status: Wrong Answer

Solution code:
def count(k):
    ret=0
    while k%2==0:
        k//=2
        ret+=1
    return ret
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    n,m=map(int,input().split())
    A=tuple(map(int,input().split()))
    cnt=count(A[0])
    for a in A:
        if cnt!=count(a):
            return 0
    dev=pow(2,cnt)
    l=A[0]//dev
    for a in A:
        l=lcm(l,a//dev)
    if m<l:
        return 0
    return (m-l)//(l*2)+1
    
if __name__=='__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
def count(k):
    ret=0
    while k%2==0:
        k//=2
        ret+=1
    return ret
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    n,m=map(int,input().split())
    A=tuple(map(int,input().split()))
    cnt=count(A[0])
    for a in A:
        if cnt!=count(a):
            return 0
    dev=pow(2,cnt)
    l=A[0]//dev
    for a in A:
        l=lcm(l,a//dev)
    return (m-l)//(l*2)+1
    
if __name__=='__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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

t = 0
while all([i%(2**(t+1))==0 for i in a]):t+=1
a = [i//(2**t) for i in a]

if any([i%2==0 for i in a]):
  print(0)
else:
  b = reduce(lambda x,y:x*(y//fractions.gcd(x,y)),a)
  print((m//b+1)//2)

Submission status: Wrong Answer

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

# 最大公約数(greatest_common_divisor)
def gcd2(a, b):
    if b == 0:
        return a * 2
    return gcd2(b, a % b)

# 最小公倍数(lowest_common_multiple)
def lcm2(a, b):
    return a * b // gcd2(a, b)

# 最小公倍数と、比べていない数字を比べ、最小公倍数を更新する
alcm = a[0]
for i in a[1:]:
    alcm = lcm2(alcm, i)

ans = (m-alcm)//(alcm*2)+1
print(ans)

Submission status: Wrong Answer

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

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

# 最大公約数(greatest_common_divisor)
def gcd2(a, b):
    if b == 0:
        return a * 2
    return gcd2(b, a % b)

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

# 最小公倍数(lowest_common_multiple)
def lcm2(a, b):
    return a * b // gcd2(a, b)

# 最小公倍数と、比べていない数字を比べ、最小公倍数を更新する
alcm = a[0]
for i in a[1:]:
    alcm = lcm(alcm, i)

# 最小公倍数と、比べていない数字を比べ、最小公倍数を更新する
alcm2 = a[0]
for i in a[1:]:
    alcm2 = lcm2(alcm, i)

ans = (m-alcm2)//alcm+1
print(ans)