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:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

N, M = MAP()
A = LIST()

l = 1
for a in A:
    if a % 2 == 1:
        print(0)
        exit()
    l = lcm(l, a)
    if l > M*2:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ans//2)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
from functools import reduce
import math
import fractions
#import numpy as np


def calc_double(n):
    return n//2


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

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


def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=[0 for i in range(N)]    
    #AA=list(map(calc_double,A))
    for i in range(N):
        buf=A[i]//2
        if buf%2==0:
            print("0")
            return
        AA[i]=buf

    
    a=lcm_list(AA)
    

    odd=M//a
    count=(odd+1)//2

    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Wrong Answer

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

    div2cnt = 0
    while A[0]//2 % (2 ** div2cnt+1) == 0:
        div2cnt += 1

    lcmval = A[0]
    for i in range(1, N):
        if A[i]//2 % (2 ** (div2cnt+1)) == 0 or A[i]//2 % (2 ** div2cnt) != 0:
            print(0)
            exit(0)
        
        lcmval = lcm(lcmval, A[i]//2)
        if lcmval > M:
            print(0)
            exit(0)
    
    print(int((M-lcmval)//(lcmval* 2)+ 1))

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

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = np.array(list(set(map(int, input().split()))), dtype=np.int64) // 2

while sum(a % 2 == 0) == len(a):
    a //= 2

if sum(a % 2 == 0) != 0:
    print(0)
    exit()

l = 1
for i in a:
    l = l * i // gcd(l, i)

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

Submission status: Wrong Answer

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

    div2cnt = 0
    while A[0]//2 % (2 ** div2cnt+1) == 0:
        div2cnt += 1

    lcmval = A[0]
    for i in range(1, N):
        if A[i]//2 % (2 ** (div2cnt+1)) == 0 or A[i]//2 % (2 ** div2cnt) != 0:
            print(0)
            exit(0)
        
        if i == 1:
            lcmval = lcm(A[i-1]//2, A[i]//2)
        else:
            lcmval = lcm(lcmval, A[i]//2)
    
    print(int((M-lcmval)//(lcmval* 2)+ 1))

def lcm(x, y):
    return x * y // fractions.gcd(x, y)
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

N, M = MAP()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
    if l > M*2:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ans//2)

Submission status: Wrong Answer

Solution code:
import sys

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

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

GCD = 1
t = a[0]
cond = 0
while t%2 == 0:
	t //= 2
	cond += 1
	
mod = 2**cond
for i in range(len(a)):
	t = a[i]
	t_div,t_mod = divmod(t,mod)
	if t_div == 0:
		print(0)
		sys.exit()
	if mod != 0:
		print(0)
		sys.exit()
	if t_div % 2 == 0:
		print(0)
		sys.exit()


	GCD = GCD*a[i] // gcd(GCD,a[i])
	
A = (2*m) // GCD
if A%2 == 1:
	A+=1

print(A//2)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = np.array(list(set(map(int, input().split()))), dtype=np.int64) // 2

b = a[0]
x = 1
while b % 2 == 0:
    x *= 2
    b //= 2

if sum(a % x != 0) != 0:
    print(0)
    exit()

l = 1
for i in a:
    l = l * i // gcd(l, i)

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

N, M = MAP()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
    if l > M:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M*2, l)
print(ans//2)

Submission status: Wrong Answer

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

count = 0

for x in range(1, m+1, 2):
    j = 0
    num2 = x // 2
    while j <= n:
        if j == n:
            count += 1
        elif x % (a[j]/2) != 0 and num2 != (a[j]/2) // 2:
                break
        j += 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))
g = reduce(gcd, A)
B = [a//g for a in A]
if all(b%2 for b in B):
    print(round(((m+1)/(reduce(mul, B)*g))))
else:
    print(0)

Submission status: Wrong Answer

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

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

n, m = map(int,input().split())
a_list = list(map(int,input().split()))
u1 = lcm_list(a_list)
u2 = lcm_list(a_list) // 2
print((m-u2) // u1 + 1)

Submission status: Wrong Answer

Solution code:
import math
import bisect
import fractions
N ,M = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))

temp = []

# max_div = 0
# for a in As:
#     temp = a
#     hoge = 0
#     while temp % 2 == 0:
#         temp //= 2
#         hoge += 1
#     max_div = max(max_div,hoge)

# print(max_div )
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
flag = 0
temp = 1
a = max(As)
co = 0
while a!= 0:
    if a % 2 == 0:
        a //=2
        co += 1
    else:
        break
n = 2 ** co
for a in As:
    if a % n != 0:
        print(0)
        exit(0)
    temp = lcm(temp,a//2)

if flag == 0 or flag == N:
    print(M // temp - (M//(temp * 2))  )
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))
B = [a//reduce(gcd, A) for a in A]
if all(b%2 for b in B):
    print(round(((m+1)/(2*reduce(mul, B)))))
else:
    print(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

A = [x >> 1 for x in A]

def merge(a, b):
    g = gcd(a, b)
    a //= g
    b //= g
    if a % 2 == 0:
        return 0
    if b % 2 == 0:
        return 0
    n = a * b * g
    if n > 10 ** 9:
        return 0
    return n

x = reduce(merge, A)
if x == 0:
    ans = 0
else:
    ans = (M//x) - (M//(2*M))

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

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

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

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

X = lcm_list(A)
T = X
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2
# print()
for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
t_ans = T // 2
if (M // t_ans) % 2 == 0:
    print((M/t_ans) // 2)
else:
    print(((M//t_ans) + 1) // 2)

Submission status: Wrong Answer

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

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

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

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[0])
    for i in range(1, N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    ans = (M-L)//(2*L)+1
    return ans

print(test())

Submission status: Wrong Answer

Solution code:
def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=a*kou//gcd(a,kou)
    if (kou//A[0])%2==0:
          print(0)
          exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

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 div2(x):
    c = 0
    while x%2==0:
        x //= 2
        c+=1
    return c

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[0])
    for i in range(1, N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    M//=L
    ans = (M-L)//(2*L)+1
    return ans

print(test())

Submission status: Wrong Answer

Solution code:

def main():
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    #from bisect import bisect_right as br
    ##c=br(A,A[-1]//2)
    amin=min(A)
    for a in A:
        kou=a*kou//gcd(a,kou)//2
        if (kou//amin)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])//2
    #from bisect import bisect_right as br
    ##c=br(A,A[-1]//2)
    amin=min(A)
    for a in A:
        kou=a*kou//gcd(a,kou)//2
        if (kou//amin)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

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

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

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

X = lcm_list(A)
T = X
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2
# print()
for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
if (M // (T//2)) % 2 == 0:
    print(M//T//2)
else:
    print((M//(T//2)+1)//2)

Submission status: Wrong Answer

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

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

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

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[i])
    for i in range(1, N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    M//=L
    ans = (M+1)//2
    return ans

print(test())

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

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

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

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

X = lcm_list(A)
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2
# print()
for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
print(ceil(M // X / 2**cnt))

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 div2(x):
    c = 0
    while x%2==0:
        x //= 2
        c+=1
    return c

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[i])
    for i in range(1, N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    ans = (M-L)//(2*L)+1
    return ans

print(test())

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))
B = [a//2 for a in A]
C = list(B)
while all((c+1)%2 for c in C):
    C = [c//2 for c in C]
if all(c%2 for c in C):
    lcm = reduce(mul, B) // reduce(gcd, B)
    print(round(((m+1)/(2*lcm))))
else:
    print(0)

Submission status: Wrong Answer

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

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

L = lcm_list(A)
print((M+1)//(L//2) - (M+1)//L)

Submission status: Wrong Answer

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

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

L = lcm_list(A)
print(M//(L//2) - M//L)

Submission status: Wrong Answer

Solution code:

from fractions import gcd
from math import ceil
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 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:
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

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

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

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

X = lcm_list(A)
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2


for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
print(ceil(M // X / 2))

Submission status: Wrong Answer

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

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

a = a // 2

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

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

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

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

X = lcm_list(A)
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2


for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
print(ceil(M // X / 2))

Submission status: Wrong Answer

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

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

ma = 0
for i in range(n):
    a[i] = a[i] // 2
    if a[i] > ma:
        ma = a[i]
l = a[0]
for i in range(1, n):
    l = lcm(l, a[i])

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import fractions
from functools import reduce
from math import ceil, floor

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

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

N, M = map(int, input().split())
A = list(map(int, input().split()))
flag1 = True
for i in range(N):
    A[i] //= 2
    if A[i] % 2 != 0:
        flag1 = False

X = lcm_list(A)
if X % 2 == 0:
    flag2 = True
else:
    flag2 = False

for i in range(N):
    if flag1 and flag2:
        if X // 2 != A[i] // 2:
            print(0)
            exit()
    elif not flag1 and not flag2:
        continue
    else:
        print(0)
        exit()
print(ceil(M // X / 2))

Submission status: Wrong Answer

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

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

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

LCM = a[0]
for i in a[1:]:
  LCM = lcm(LCM, i)

x = (m * 2) // LCM
y = (m * 2) // (LCM * 2)

if LCM > m:
    print(0)
else:
    print(x - y)

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
an=[int(i) for i in input().split()]
import fractions
ans=an[0]
for i in range(1, n):
    ans = ans * an[i] // fractions.gcd(ans, an[i])

def count2(i):
    if i%2==0:
        c=0
        while i%2==0:
            i//=2
            c+=1
        return c
    else:
        return 0
    
c2=count2(ans)

for ak in an:
    if ak%(2**c2)==0:
        d=1
        pass
    else:
        d=0
        break

if d==0:
    print(0)
else:
    lca=ans//(2**(c2-1))
    if (m//lca)%2==0:
        print((m//lca)//2)
    else:
        print(((m//lca)+1)//2)

Submission status: Wrong Answer

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

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

b = a[0]
x = 1
while b % 2 == 0:
    x *= 2
    b //= 2

for i in range(len(a)):
    if a[i] % x != 0:
        print(0)
        exit()
    else:
        a[i] //= x
m //= x

l = 1
for i in a:
    l = l * i // gcd(l, i)
    if l > m:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
N,M=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])
ans = ans // 2
print(int(M/ans + 1)//2)

Submission status: Wrong Answer

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

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

b = a[0]
x = 1
while b % 2 == 0:
    x *= 2
    b //= 2

for i in range(len(a)):
    if a[i] % x != 0:
        print(0)
        exit()
    else:
        a[i] //= x
m //= x

l = 1
for i in a:
    l = l * i // gcd(l, i)
print((m // l + 1) // 2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions
N,M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
tmp1 = 1
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
for i in set(A):
    tmp2 = lcm(tmp1,(i//2))
    tmp1 = tmp2 
    #print(lcm(tmp,(i//2)),tmp,i//2)
ans = M//tmp1
ans = ((ans+1) //2)
print(ans)

Submission status: Wrong Answer

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

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

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


LCM = a[0]
for i in a[1:]:
  LCM = lcm(LCM, i)

x = (m * 2) // LCM
y = (m * 2) // (LCM * 2)
print(x - y)

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
an=[int(i) for i in input().split()]
import fractions
ans=an[0]
for i in range(1, n):
    ans = ans * an[i] // fractions.gcd(ans, an[i])

def count2(i):
    if i%2==0:
        c=0
        while i%2==0:
            i//=2
            c+=1
        return c
    else:
        return 0
    
c2=count2(ans)

for ak in an:
    if ak%(2**c2)==0:
        d=1
        pass
    else:
        d=0
        break

if d==0:
    print(0)
else:
    lca=ans//(2**c2)
    if (m//lca)%2==0:
        print((m//lca)//2)
    else:
        print(((m//lca)+1)//2)

Submission status: Wrong Answer

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

A=a[0]

def lcm(x,y):
    cnt=0
    Z=x
    while (Z%2)==0:
        Z=(Z/2)
        cnt+=1
    X=x
    Y=y
    if Y%(2**cnt)!=0 or (Y//(2**cnt))%2==0:
        print(Y//(2**cnt),Z)
        exit()
    if X<Y:
        X,Y=Y,X
    while X%Y!=0:
        X,Y=Y,X%Y
    return (x*y)//Y
    
for i in range(N):
    if a[i]%2==1:
        print(0)
        exit()
    A=lcm(A,a[i])
    if A%4==0:
        print(0)
        exit()
    if A>M:
        print(0)
        exit()

M-=A//2
print(1+M//A)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = np.array(list(set(map(int, input().split()))), dtype=np.int64) // 2

b = a[0]
x = 1
while b % 2 == 0:
    x *= 2
    b //= 2

if sum(a % x != 0):
    print(0)
    exit()
else:
    a //= x
    m //= x

l = 1
for i in a:
    l = l * i // gcd(l, i)
print((m // l + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd


def cnt(x):
    a = 0
    while True:
        r = x % 2
        if r == 1:
            break
        else:
            a += 1
            x //= 2


read = sys.stdin.read
N, M, *a = map(int, read().split())
a = list(set(a))
b = [cnt(i) for i in a]
if len(set(b)) != 1:
    print(0)
    exit()

m = 2 * M

lcm = a[0]
for i in a:
    g = gcd(lcm, i)
    lcm = lcm * i // g
    if lcm > m:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

def solve(A, M):
    A = [x // 2 for x in A]
    g = reduce(gcd, A)
    lcm = 1
    for c in A:
        j = c // g
        if j % 2 == 0:
            return 0
        k = gcd(lcm, j)
        lcm *= j // k
    return (M // lcm + 1) // 2


def main():
    N, M = map(int, input().split())
    A = map(int, input().split())
    ans = solve(A, M)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!python3

def iim():
    return map(int, input().rstrip().split())

from fractions import gcd

def nbit(x):
    if x == 0: return 0

    n = 0
    while x & 1 == 0:
        x >>= 1
        n += 1
    return n

def resolve():
    N, M = iim()
    a = list(iim())

    y = a[0]
    nb = nbit(y)
    for x in a[1:]:
        if nbit(x)  != nb:
            print(0)
            return

        y *= x // gcd(y, x)


    print(M//y + 1)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

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

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

c = 0
n = a[0]//2
while n % 2 == 0:
    n//=2
    c+=1

a = list(map(lambda x: x//(2**(c+1)), a))
M //= 2**c

if all([True if v%2**c == 0 and v%2**(c+1) != 0 else False for v in a]):
    L = a[0]
    if N >= 2:
        for i in range(1, N):
            L = lcm(L, a[i])
    if 1 <= L <= M:
        ans = (M-L)//(L*2)+1

print(ans)

Submission status: Wrong Answer

Solution code:
# 2020/01/10

from fractions import gcd

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

aa=list(map(lambda x: x//2,a))
lcm=aa.pop()
for e in aa:
    lcm=(lcm*e)//gcd(lcm,e)
print(-(-m//lcm//2) if m>=lcm else 0)

Submission status: Wrong Answer

Solution code:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def kn(h):
  l=0
  while h%2==0:
    h=h//2
    l+=1
  return l
  
k=1
flag=kn(A[0]//2)
for a in A:
  a//=2
  k=lcm(k,a)
  if flag != kn(a):
    print(0);exit()
  
if k==1:
  k=3
print(int(M//k//2+M//k%2))

Submission status: Wrong Answer

Solution code:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def kn(h):
  l=0
  while h%2==0:
    h=h//2
    l+=1
  return l
  
k=1
flag=kn(A[0]//2)
for a in A:
  a/=2
  k=lcm(k,a)
  if flag != kn(a):
    print(0);exit()
  
if k==1:
  k=3
print(int(M//k//2+M//k%2))

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

Submission status: Wrong Answer

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

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

def _lcm(a,b):
    return (a*b) // _gcd(a,b)

lcm = A[0] 
for ai in A[1:]:
    lcm = _lcm(lcm, ai)

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

def solve(A, M):
    s = set(A)
    a = []
    for c in s:
        a.append(c // 2)
    g = reduce(gcd, a)
    lcm = 1
    for c in a:
        j = c // g
        if j % 2 == 0:
            return 0
        lcm *= j
    return (M // lcm + 1) // 2


def main():
    N, M = map(int, input().split())
    A = map(int, input().split())
    ans = solve(A, M)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions


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


# 2で割れる回数を数える
def f(x):
    t = 0
    while (x % 2 == 0):
        x //= 2
        t += 1
    return t


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

cnt = f(a[0])
for i in range(n):
    # 割れる回数が一致しなければ不可
    if cnt != f(a[i]):
        print(0)
        exit()
    a[i] >>= cnt
m >> cnt
num = 1
for i in range(n):
    num = lcm(num, a[i])
    if num > m:
        print(0)
        exit()
m //= num
ans = (m + 1) // 2
print(ans)