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 = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
    kotae_2 =0
else:
    kotae_2 = math.ceil(M //saisyou_koubaisu_2 ) # Mの中で半公倍数を数える
    kotae = math.ceil(kotae_2/2)  # 偶数は除く
print(kotae)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
kotae =0
A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
if saisyou_koubaisu_2 % 2 ==0:
    kotae =0
else:
    kotae = math.ceil(M_2 / saisyou_koubaisu_2 ) # Mの中で半公倍数を数える
#kotae_2 = math.ceil(kotae/2)  # 偶数は除く
print(kotae)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

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

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#2のt乗で割り切れるか、最大のｔ
def A_2_tjoudewarikereru(n):
    count =0
    while True:
        if n % 2 == 0:
            count += 1
            n = n//2
        else:
            break
           
    return count

A_2_yakusu_tjou = min([ A_2_tjoudewarikereru(i) for i in A]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
kotae = math.ceil(M_2 / saisyou_koubaisu_2 ) # Mの中で半公倍数を数える
#kotae_2 = math.ceil(kotae/2) +1 # 偶数は除く
print(kotae)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


#素因数分解
def soinsu_bunkai(n):
    pf ={}
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            pf[i]=pf.get(i,0)+1
            n//=i
    if n>1:pf[n]=1
    return pf

A_soinsubunkai=[soinsu_bunkai(i) for i in A]
A_2_yakusu_tjou = min([ i[2] for i in A_soinsubunkai]) #2のt乗で割り切れる最大のt
A_2_yakusu = 2 ** A_2_yakusu_tjou
M_2 = M // A_2_yakusu

# 最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A_2 =[i // A_2_yakusu for i in A]
saisyou_koubaisu_2 = lcm_list(A_2)
# if (saisyou_koubaisu_2) % 2 ==0: #最小公倍数の半分が偶数の場合「０」
  #  kotae = 0
# else:
kotae = math.ceil(M_2 / saisyou_koubaisu_2 ) # Mの中で半公倍数を数える
   
print(kotae)

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
B  = list(map(int,input().split()))

def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M*2:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M*2:
            return -1 
    return x

        
x = lcmn(B)
if x == -1:
    print(0)
    exit(0)
if x > M * 2 :
    print(0)
    exit(0)
else:
    print(((M-x //2)//x+1))

Submission status: Wrong Answer

Solution code:
import fractions
import math
from functools import reduce
import sys
sys.setrecursionlimit(10**8)


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


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


n, m = map(int, input().split())
a = list(map(int, input().split()))
count = 0
while all(x % 2 == 0 for x in a):
    count += 1
    a = list(map(lambda x: x//2, a))

lcm = lcm(a)
print(m // (lcm * (2 ** (count - 1))) - m // (lcm * (2 ** count)))

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
B  = list(map(int,input().split()))

def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M*2:
            return -1 
    return x

        
x = lcmn(B)
if x == -1:
    print(0)
    exit(0)
if x > M * 2 :
    print(0)
    exit(0)
else:
    print(((M-x //2)//x+1))

Submission status: Wrong Answer

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# ヒントの数字の最小公倍数
from functools import reduce
import fractions
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

saisyou_koubaisu_han = lcm_list(A) //2
if (saisyou_koubaisu_han) % 2 ==0: #最小公倍数が偶数の場合「０」
    kotae = 0
else:
    kotae = math.ceil(M // saisyou_koubaisu_han /2) # Mの中で半公倍数を数える
    #kotae =[ i for i in range(a) if (i+1) % 2 ==1 ] # aの内、奇数
    
    #print(len(kotae))

print(kotae)

Submission status: Wrong Answer

Solution code:
import fractions
import math
from functools import reduce
import sys
sys.setrecursionlimit(10**8)


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


def lcm(numbers):
    return reduce(lcm2, numbers, 1)


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

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

Submission status: Wrong Answer

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

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    def my_divide(num, count=0):
        if num % 2 == 0:
            return my_divide(num//2, count+1)
        else:
            return count
    
    def calc_lcm(x, y):
        return (x * y) // gcd(x, y)
        

    n, m = mi()
    a = lmi()
    b = [elm//2 for elm in a]
    num_two = [None] * n
    divided_by_pow_two = [None] * n

    for i in range(n):
        num = my_divide(b[i])
        num_two[i] = num
        divided_by_pow_two[i] = b[i] // (2 ** num)

    if len(set(num_two)) != 1:
        print(0)
    else:
        lcm = divided_by_pow_two[0]
        for elm in b:
            lcm = calc_lcm(lcm, elm)
        lcm *= (2 ** num_two[0])
        # print(lcm)
        print(math.ceil((m // lcm) / 2))
            

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(1,len(a)):
   sk = sk * a[i] // fractions.gcd(sk,a[i])
x = (m+(sk//2))//sk
print(x)

Submission status: Wrong Answer

Solution code:
import fractions
n,m = map(int,input().split())
a = list(map(int,input().split()))
sk = a[0]
if len(a)==1:
    x = (m+(sk//2))//sk
else:
    seki=a[0]
    ky=a[0]
    for i in range(1,len(a)):
        seki = sk * a[i]
        ky = fractions.gcd(sk,a[i])
        sk = seki // ky
    x = (m+(sk//2))//sk
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = list(map(int,input().split()))
ansli = list()
count = 1
a0 = a.pop(0)
while True:
    num = int(a0*(count+0.5))
    if num >M:
        break
    else:
        ansli.append(num)
    count += 1

for ai in a:
    stack = list()
    for ansj in ansli:
        if (ansj/ai) % 0.5 == 0.0:
            stack.append(ansj)
    ansli = stack
print(len(ansli))

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# A が2で何回割れるか
N, M = lr()
A = lr()
A = [x // 2 for x in A]
cnt = 0
while all(x%2 == 0 for x in A):
    cnt += 1
    A = [x // 2 for x in A]

if any(x%2 == 0 for x in A):
    print(0); exit()
lcm = 1
for a in A:
    lcm *= a // gcd(lcm, a)

answer = M // lcm - M // (2 * lcm)
print(answer)
# 21

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# A が2で何回割れるか
N, M = lr()
A = lr()
A = [x // 2 for x in A]
cnt = 0
while all(x%2 == 0 for x in A):
    cnt += 1
    A = [x // 2 for x in A]

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

answer = M // (2 ** cnt * lcm) - M // (2 ** (cnt+1) * lcm)
print(answer)
# 21

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# A が2で何回割れるか
N, M = lr()
A = lr()
A = [x // 2 for x in A]
cnt = 0
while all(x%2 == 0 for x in A):
    cnt += 1
    A = [x // 2 for x in A]

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

answer = M // lcm - M // (2 * lcm)
print(answer)
# 21

Submission status: Wrong Answer

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


def countDiv2(k):
    sum = 0
    while k // 2 == 0:
        k //= 2
        sum += 1
    return sum


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    shouldDivisable = 2**countDiv2(a[0])
    shouldNotDivisable = shouldDivisable * 2
    for i in range(1, len(a)):
        if a[i] % shouldDivisable != 0 or a[i] % shouldNotDivisable == 0:
            print(0)
            exit()
    LCM = b[0] if N == 1 else lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M < LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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:
#!/usr/bin/env python3
import sys
from fractions import gcd


def countDiv2(k):
    sum = 0
    while k // 2 == 0:
        k //= 2
        sum += 1
    return sum


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    shouldDivisable = 2**countDiv2(b[0])
    shouldNotDivisable = shouldDivisable * 2
    for i in range(1, len(b)):
        if b[i] % shouldDivisable != 0 or b[i] % shouldNotDivisable == 0:
            print(0)
            exit()
    LCM = b[0] if N == 1 else lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M < LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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:
#!/usr/bin/env python3
import sys
from fractions import gcd


def countDiv2(k):
    sum = 0
    while k // 2 == 0:
        k //= 2
        sum += 1
    return sum


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    div2Count = countDiv2(b[0])
    for i in range(1, len(b)):
        if countDiv2(b[i]) != div2Count:
            print(0)
            exit()
    LCM = b[0] if N == 1 else lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M < LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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:
#!/usr/bin/env python3
import sys
from fractions import gcd


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    LCM = b[0] if N == 1 else lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M < LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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:
# define
a = [0] * int(1e5 + 100)
# functions
def _gcd(a, b):
    if a % b == 0 : return b
    if b % a == 0 : return a
    while a != 1 and b != 1:
        if a > b: a %= b
        else : b %= a
        if a % b == 0: return b
        if b % a == 0: return a
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = _gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > 2 * m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Wrong Answer

Solution code:
# define
a = [0] * int(1e5 + 100)
# functions
def _gcd(a, b):
    if a % b == 0 : return b
    if b % a == 0 : return a
    while a != 1 and b != 1:
        if a > b: a %= b
        else : b %= a
        if a % b == 0: return b
        if b % a == 0: return a
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = _gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Wrong Answer

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    #gcd = math.gcd(lcm, a[i])
    #lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Wrong Answer

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]
exit()
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Wrong Answer

Solution code:
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N,M = inputlist()
a = inputlist()
ans = 0
def binary_search(i):
    le = -1
    ri = 10**9+1
    while ri - le > 1:
        mid = (ri+le)//2
        if i*(mid+0.5) == M:
            return mid
        if i*(mid+0.5) > M:
            ri = mid
        if i*(mid+0.5) < M:
            le = mid
    return le
for i in range(N):
    k = binary_search(a[i])
    ans = max(ans,a[i]*(k+0.5))
ans = int(ans)
from fractions import gcd
def lcm(x,y) :
    return(x*y) // gcd(x,y)
sam = a[0]
for i in range(1,N):
    sam = lcm(a[i],sam)
print(ans,sam)
if ans // sam == 0:
    print(0)
    exit()
if ans % sam == 0:
    print(ans//sam)
    exit()
if ans % sam != 0:
    print(ans//sam + 1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
for i in range(N) :
    A[i] = A[i] // 2
k = 1
count = 0
a = A[0]
import fractions
from fractions import gcd
def lcm(x,y) :
    return(x*y) // fractions.gcd(x,y)
for i in range(N) :
    if A[i] % 2 == 0 :
        k = 0
j = 1
if k == 1 :
    for i in range(1,N) :
        a = lcm(a,A[i])
    la = M // a
    if la % 2 == 0 :
        count = la//2
    else :
        count = la//2 + 1
print(count)

Submission status: Wrong Answer

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

Bs = [a//2 for a in As]

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

lcd = 1
for b in Bs:
    lcd = (lcd * b) // gcd(lcd, b)

ans = M / (2*lcd) + 1/2
print(int(ans))

"""
2 75
6 10
"""

Submission status: Wrong Answer

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

Bs = [a//2 for a in As]

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

lcd = 1
for b in Bs:
    lcd = (lcd * b) // gcd(lcd, b)
# print(lcd) 

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

Submission status: Wrong Answer

Solution code:
# 12:35~
from fractions import gcd

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

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

#%%
LCM = 1
for a in A:
    LCM = lcm(LCM,a//2)

ans = 0
if LCM&1:
    if LCM<=M:
        ans += 1
        M -= LCM
        ans += M//(2*LCM)

print(ans)

Submission status: Wrong Answer

Solution code:
# 12:35~
from fractions import gcd

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

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

#%%
LCM = 1
for a in A:
    LCM = lcm(LCM,a//2)

ans = 0
if LCM&1:
    if LCM<M:
        ans += 1
        M -= LCM
        ans += M//(2*LCM)

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
c = 0
while a[0] % 2 == 0:
    a[0] //= 2
    c += 1
a[0] *= 2**c
for ai in a[1:]:
    if ai % 2 or (ai // 2) % 2 == 0:
        print(0)
        break
else:
    lcm = reduce(lambda x, y: x * y // gcd(x, y), a) // 2
    print(m // lcm - m // (2 * lcm))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
c = 0
while a[0] % 2 == 0:
    a[0] //= 2
    c += 1
a[0] *= 2**c
for ai in a[1:]:
    print(ai, ai % 2, (ai // 2) % 2)
    if ai % 2 or (ai // 2) % 2 == 0:
        print(0)
        break
else:
    lcm = reduce(lambda x, y: x * y // gcd(x, y), a) // 2
    print(m // lcm - m // (2 * lcm))

Submission status: Wrong Answer

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


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


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


N, M = map(int, input().split())
*A, = map(int, input().split())
if len(set([count(a) for a in A])) > 1:
    print(0)
else:
    A = [a//2 for a in A]
    while len(A) > 1:
        a = A.pop()
        b = A.pop()
        A.append(lcm(a, b))
    t = A.pop()
    print(-(-M//t)//2)

Submission status: Wrong Answer

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

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

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

def bit(a):
    res = 0
    _a = a
    while _a % 2 == 0:
        _a /= 2
        res += 1
    return res

count = bit(A[0])
for i in range(1, len(A)):
    if bit(A[i]) != count:
        print(0)
        exit()
half_A = [ a // 2 for a in A]

min_X = half_A[0]
for a in half_A:
    min_X = lcm(a, min_X)
    if min_X > M:
        print(0)
        exit()

res = M // min_X

print(int((res+1)//2))

Submission status: Wrong Answer

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

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

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

def bit(a):
    res = 0
    _a = a
    while _a % 2 == 0:
        _a /= 2
        res += 1
    return res

count = bit(A[0])
for i in range(1, len(A)):
    if bit(A[i]) != count:
        print(0)
        exit()
half_A = [ a // 2 for a in A]

min_X = half_A[0]
for a in half_A:
    min_X = lcm(a, min_X)
    if min_X > M:
        print(0)
        exit()

res = M // min_X
print(int(ceil(res/2)))

Submission status: Wrong Answer

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

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

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

def bit(a):
    res = 0
    _a = a
    while _a % 2 == 0:
        _a /= 2
        res += 1
    return res

count = bit(A[0])
for i in range(1, len(A)):
    if bit(A[i]) != count:
        print(0)
        exit()
half_A = [ a / 2 for a in A]

min_X = reduce(lcm, half_A)
res = M // min_X
print(int(ceil(res/2)))

Submission status: Wrong Answer

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

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

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

def bit(a):
    res = 0
    _a = a
    while _a % 2 == 0:
        _a /= 2
        res += 1
    return res

half_A = [ a / 2 for a in A]
counts = [bit(a) for a in A]
if not all([counts[i] == counts[i-1] for i in range(1, len(counts))]):
    print(0)
    exit()

min_X = reduce(lcm, half_A)
res = M // min_X
print(int(ceil(res/2)))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

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

half_A = [ a / 2 for a in A]
min_X = reduce(lcm, half_A)

res = M // min_X
if not all([a % 4 != 0 for a in A]):
    print(0)
elif res % 2 == 0:
    print(int(res//2))
else:
    print(int(res//2+1))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

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

half_A = [ a / 2 for a in A]
min_X = reduce(lcm, half_A)

res = M // min_X
if res % 2 ==  0:
    print(0)
elif res % 2 == 0:
    print(int(res//2))
else:
    print(int(res//2+1))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

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

half_A = [ a / 2 for a in A]
min_X = reduce(lcm, half_A)

res = M // min_X
if res == 0:
    print(0)
elif res % 2 == 0:
    print(int(res//2))
else:
    print(int(res//2+1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

n, m = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
lcm = reduce(lambda x, y: x * y // gcd(x, y), a)
print(int(m // lcm - m // (2 * lcm)))

Submission status: Wrong Answer

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

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

for a in A:
    if a % 4 == 0:
        print(0)
        exit()

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

lcm_all = reduce(lcm, A)

def dividable(n, e):
    return (n - e/2) % e == 0

i = 0
max_a = max(A)
min_gcd = -1
while True:
    n = max_a * i + max_a / 2
    ok = all([dividable(n, a) for a in A])
    if ok:
        min_gcd = n
        break
    i += 1
if M < min_gcd:
    print(0)
else:
    print(int((M - min_gcd) / lcm_all) + 1)

Submission status: Wrong Answer

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

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

for a in A:
    if a % 4 == 0:
        print(0)
        exit()

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

lcm_all = reduce(lcm, A)

def dividable(n, e):
    return (n - e/2) % e == 0

i = 0
max_a = max(A)
min_gcd = -1
while True:
    n = max_a * i + max_a / 2
    ok = all([dividable(n, a) for a in A])
    if ok:
        min_gcd = n
        break
    i += 1

print(int((M - min_gcd) / lcm_all) + 1)

Submission status: Wrong Answer

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

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

for a in A:
    if a % 4 == 0:
        print(0)
        exit()

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

lcm_all = reduce(lcm, A)

def dividable(n, e):
    return (n - e/2) % e == 0

i = 0
max_a = max(A)
min_gcd = -1
while True:
    n = max_a * i + max_a / 2
    ok = all([dividable(n, a) for a in A])
    if ok:
        min_gcd = n
        break
    i += 1

print(ceil((M - min_gcd + 1) / lcm_all))

Submission status: Wrong Answer

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

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

n,m = map(int,input().split())
li = list(map(int,input().split())) 
num = 1
for a in li:
  num = lcm(a,num)
  
m -= num//2
if m < 0:
  print(0)
else:
  print(m//num+1)