Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
  while (y):
    r = x % y
    x = y
    y = r
  return x

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

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

cur = 1

fail = False
for x in a:
  cur = lcm(cur, x // 2)
  if (cur > m):
    fail = True
    break
if (fail):
  print(0)
else:
  foo = m // cur
  k = (foo - 1) // 2
  print(k + 1)

Submission status: Wrong Answer

Solution code:
from functools import reduce

def gcd_base(x, y):
    if x % y:
        return gcd_base(y, x%y)
    return y

def gcd(numbers):
    return reduce(gcd_base, numbers)

def lcm_base(x, y):
    res = (x * y) // gcd_base(x, y)
    return res if res <= 1000000007 else 0

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

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if any([i%4==0 for i in a]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l)
    if x==0:
        print(0)
    else:
        print((m//x+1)//2)

Submission status: Wrong Answer

Solution code:
def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


try:
    from math import gcd
except ImportError:
    from fractions import gcd

n, m = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

n = 1
c = prime_factor(A[0])[0][1]
for a in A:
    if c != prime_factor(n)[0][1]:
        print(0)
        exit()
    n = (n*a)//gcd(n, a)

n //= 2

if n > m:
    ans = 0
else:
    ans = m//n
    ans = (ans+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


try:
    from math import gcd
except ImportError:
    from fractions import gcd

n, m = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

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

n //= 2

if n > m:
    ans = 0
else:
    ans = m//n
    ans = (ans+1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


try:
    from math import gcd
except ImportError:
    from fractions import gcd

n, m = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

n = 1
for a in A:
    n = (n*a)//gcd(n, a)
if n > m*2:
    ans = 0
else:
    ans = 2*m//n+1


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

def f(n):
    cnt = 0
    while n % 2 == 0:
        n //= 2
        cnt += 1
    return cnt
t = f(A[0])
for i in range(N):
    if f(A[i]) != t:
        print(0)
        exit(0)
    A[i] >>= t

M >>= t
lcm = reduce(lambda a, b: (a * b) // gcd(a, b), A)
if lcm > M:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

def f(n):
    cnt = 0
    while n % 2 == 0:
        n //= 2
        cnt += 1
    return cnt
t = f(A[0])
for i in range(N):
    if f(A[i]) != t:
        print(0)
        exit(0)
        A[i] >>= t

M >>= t
lcm = reduce(lambda a, b: (a * b) // gcd(a, b), A)
if lcm > M:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

def f(n):
    cnt = 0
    while n % 2 == 0:
        n //= 2
        cnt += 1
    return cnt
t = f(A[0])
for i in range(1, N):
    if f(A[i]) != t:
        print(0)
        exit(0)
if min_cm > M:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)
 
# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))
if not all(map(lambda x: (min_cm // x) % 2 == 1, A)):
    print(0)
    exit(0)
if min_cm > M:
    print(0)
    exit(0)
ans = (M // min_cm) // 2 + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))
z = min_cm
while not all(map(lambda x: (min_cm // x) % 2 == 1, A)):
    z += min_cm
if z > M:
    print(0)
    exit(0)
ans = (M // z) // 2 + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))
while not all(map(lambda x: (min_cm // x) % 2 == 1, A)):
    min_cm *= 3
if min_cm > M:
    print(0)
    exit(0)
ans = (M // min_cm) // 2 + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


from functools import reduce
# from math import *
from fractions import *
N, M = map(int, readline().split())
A = list(sorted(map(lambda x: int(x) // 2, readline().split())))
min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)

# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))
if not all(map(lambda x: (min_cm // x) % 2 == 1, A)):
    min_cm *= 2
if min_cm > M:
    print(0)
    exit(0)
ans = (M // min_cm) // 2 + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[v//2 for v in a]

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)
if l>m:
  print(0)
  exit()
print(1+(m-l)//(l*2))
#print(lcm_list(a))

Submission status: Wrong Answer

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

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

for i in C:
    if koubai // i % 2 == 0:
        print(0)
        exit()     
print(int((M//koubai+1)//2))

Submission status: Wrong Answer

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

C=[i/2 for i in A]
koubai=C[0]
for i in range(1,N):
     a=fractions.gcd(C[i],koubai)
     koubai=C[i]*koubai/a
     if koubai>M:
         break
         print(0)
for i in C:
    if koubai // i % 2 == 0:
        print(0)
        exit()     
print(int((M//koubai+1)//2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
import fractions
def bisect(n):
  i=0
  while n%2!=1:
    n=n/2
    i+=1
  return i
B=[bisect(A[i]) for i in range(N)]
if not(all(i==B[0] for i in B)):
       print(0)
else:
  C=[i/2 for i in A]
  koubai=C[0]
  for i in range(1,N):
       a=fractions.gcd(C[i],koubai)
       koubai=C[i]*koubai/a
       if koubai>M:
         break
         print(0)
  print((M//koubai+1)//2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
import fractions
def bisect(n):
  i=0
  while n%2!=1:
    n=n/2
    i+=1
  return i
B=[bisect(A[i]) for i in range(N)]
if not(all(i==B[0] for i in B)):
       print(0)
else:
  C=[i/2 for i in A]
  koubai=C[0]
  for i in range(1,N):
       a=fractions.gcd(C[i],koubai)
       koubai=C[i]*koubai/a
       if koubai>M:
         break
         print(0)
  l=int(M/koubai)
  print(int((l+1)/2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
import fractions
def bisect(n):
  i=0
  while n%2!=1:
    n=n/2
    i+=1
  return i
B=[bisect(A[i]) for i in range(N)]
if not(all(i==B[0] for i in B)):
       print(0)
else:
  C=[i/2 for i in A]
  koubai=C[0]
  for i in range(1,N):
       a=fractions.gcd(C[i],koubai)
       koubai=C[i]*koubai/a
       if koubai>M:
         break
         print(0)
  print(round(M/(2*koubai)))

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############
N, M = getNM()
A = getList()

def half_com_mul(num_list):
    list_alta = [i // 2 for i in num_list]
    exist_judge = list_alta[0] % 2
    # それぞれを２でわった数に奇数と偶数両方ある時
    # 半公倍数は存在しない（起点が違うため)
    for i in list_alta[1:]:
        if i % 2 != exist_judge:
            return float('inf')

    lcm = 1
    list_set = list(set(list_alta))
    limiter = max(num_list)
    for i in list_set:
        lcm *= i
        # 非常用
        if lcm > limiter * (10 ** 12):
            return float('inf')

    div_gcd = list_set[0]
    for i in list_set[1:]:
        div_gcd = gcd(div_gcd, i)
        if div_gcd == 1:
            break
    lcm //= div_gcd
    res = lcm

    while True:
        flag = True
        for i in list_alta:
            if res % (i * 2) != i:
                flag = False
        if flag:
            break
        res += lcm
        # 非常用
        if res > 10 ** 12:
            break

    return res

def lcm(num_list):
    list_set = list(set(num_list))
    lcm = 1

    for i in list_set:
        lcm *= i

    div_gcd = list_set[0]
    for i in list_set[1:]:
        div_gcd = gcd(div_gcd, i)
        if div_gcd == 1:
            break
    lcm //= div_gcd

    return lcm

ans = M - half_com_mul(A)
if ans >= 0:
    print(ans // lcm(A) + 1)
else:
    print(0)

Submission status: Wrong Answer

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

now = 1

from fractions import gcd

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

for i in range(1,n):
    now = lcm(now,i//2)

if now == 0:
    print(0)
else:
    print(m//now+m//(now*2))

Submission status: Wrong Answer

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

now = 1

from fractions import gcd

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

for i in a:
    now = lcm(now,i//2)

print(m//now-m//(now*2))

Submission status: Wrong Answer

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

now = 1

from fractions import gcd

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

for i in a:
    now = lcm(now,i//2)

ima = (m//now)//2

print(ima)

Submission status: Wrong Answer

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

now = 1

from fractions import gcd

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

for i in a:
    now = lcm(now,i//2)

ima = (m//now+1)//2

print(ima)

Submission status: Wrong Answer

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

now = 1

from fractions import gcd

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

for i in a:
    now = lcm(now,i//2)

print(m//now-(m//now)//2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


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

    return gcd(y % x, x)


def sieve(x):
    is_prime = [True] * (x + 1)
    is_prime[0] = is_prime[1] = False
    ret = []
    for i in range(2, x + 1):
        if is_prime[i]:
            ret.append(i)
            for j in range(i * 2, x + 1, i):
                is_prime[j] = False

    return ret


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

aa = [e // 2 for e in a]

for i, e in enumerate(aa):
    if i == 0:
        base = 0
        while e % 2 == 0:
            e //= 2
            base += 1

    else:
        cnt = 0
        while e % 2 == 0:
            e //= 2
            cnt += 1

        if cnt != base:
            print(0)
            exit()

primes = sieve(10 ** 5)
d = defaultdict(int)

for e in aa:
    for p in primes:
        cnt = 0
        while e % p == 0:
            e //= p
            cnt += 1

        d[p] = max(d[p], cnt)

lcm = 1
for k, v in d.items():
    lcm *= pow(k, v)

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0] // 2
for i in a:
    ans *= (i // 2) // gcd(ans, i // 2)
print(ceil((m // ans) / 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])
print((M-ans//2)//ans+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def solve(N: int, M: int, a: "List[int]"):
    a = [t//2 for t in list(set(a))]

    g = 1
    for t in a:
        g = gcd(g, t)

    ag = [t//g for t in a] 

    mu = 1
    for t in ag:
        if t%2==1:
            mu*= t//gcd(t,mu)
        else:
            print(0)
            return
    # print(g)
    # print(mu)
    print((M//(mu*g)+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:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def solve(N: int, M: int, a: "List[int]"):
    a = [t//2 for t in list(set(a))]

    g = 1
    for t in a:
        g = gcd(g, t)

    ag = [t//g for t in a] 

    mu = 1
    for t in ag:
        if t%2==1:
            mu*= t
        else:
            print(0)
            return
    # print(g)
    # print(mu)
    print((M//(mu*g)+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:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def solve(N: int, M: int, a: "List[int]"):
    a = [t//2 for t in list(set(a))]

    g = 1
    for t in a:
        g = gcd(g, t)

    ag = [t//g for t in a]

    mu = 1
    for t in ag:
        if t%2==1:
            mu*= t
        else:
            print(0)
            return
    # print(mu)
    print((M//mu+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:
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def solve(N: int, M: int, a: "List[int]"):
    a = [t//2 for t in list(set(a))]

    g = 1
    for t in a:
        g = gcd(g, t)

    ag = [t//g for t in a]

    mu = 1
    for t in ag:
        if t%2==1:
            mu*= t
        else:
            print(0)
            return
    print(mu)
    print((M//mu+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:
import numpy as np
N,M = map(int, input().split())
a = list(map(int, input().split()))

a = list(set(a))	# 重複を除去
a = list(np.array(a)/2)
a.sort()
target = a.pop(-1)
for i in range(len(a)-1, -1,-1):
  b, c = target, a[i]
  while 1:
    tmp = b % c
    if tmp != 0:
      b = c
      c = tmp
    else:
      if c == 1:
        target = target*a[i]
      elif b/c == 1:
        target = target*a[i]/c
      else:
        target = target*a[i]/min(c,b/c)
      break
out = int(M/target)
out = out - int(out/2)
print(out)

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

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

lcm = lcm_list(A)
p = M // lcm
if p % 2 == 0:
  ans = p // 2
else:
  ans = (p + 1) // 2
  
print(ans)

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

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

def half(a, b):
  if a > b:
    a, b = b, a
  x = int(b // 2)
  y = int(a // 2)
  p = 0
  while (p == 0):
    if (x - y) % a == 0:
      p = 1
    else:
      x += b
  return x

ans = A[0]
for i in range(N - 1):
  ans = half(ans, A[i + 1])
  
lcm = lcm_list(A)
#print(lcm, ans)
answer = 1
if M < ans:
  answer = 0
else:
  M = M - ans
  answer += M // lcm
  
print(answer)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)

from fractions import gcd


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, m = geta(int)
    a = tuple(geta(int))

    g = a[0] // 2
    for ai in a[1:]:
        ai2 = ai // 2
        g = (g * ai2) // gcd(g, ai2)

    print((m + g) // (g * 2))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

temp = S[0]
cnt = 0
while temp%2 == 1:
    temp //= 2
    cnt += 1
temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
    if S[i]%(2**cnt) == 1 or (S[i]//(2**cnt))%2 == 0:
        print(0)
        break
else:      
    if temp//2 > M:
        print(0)
    else:
        print((M-temp//2)//temp+1)

Submission status: Wrong Answer

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

temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
if temp//2 > M:
    print(0)
else:
    print((M-temp//2)//temp+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def l(a,b):return a*b//gcd(a,b)
def L(N):return reduce(l,N)
n,m=map(int,input().split())
A=list(map(lambda x:int(x)//2,input().split()))
a=A[0]
c=0
while(a%2==0):
  a//=2
  c+=1
if not all([a%(2**c)==0 for a in A]):
  print(0)
  exit()
a=L(A)
print((m+a)//(2*a))

Submission status: Wrong Answer

Solution code:
import 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)
    
N,M=map(int,input().split())
A=set(map(int,input().split()))
cnt=0
B=[]
C=[]
D=[]
for i in A:
    tmp=(i/2)
    if tmp%2!=0:
        B.append(i)
    else:
        C.append(i)
for i in C:
    tmp=(i/2)
    if tmp%2==0:
        D.append(i)
#print(B)        
q=lcm(*A)
#print(D)
if (len(A)==len(B) or len(A)==len(C)) and len(A)!=len(D):
    if 2*M<q:
        print(0)
    elif (2*M//q)%2==0:
        print(2*M//(2*q))
    else:
        print(2*M//(2*q)+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import 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)
    
N,M=map(int,input().split())
A=set(map(int,input().split()))
cnt=0
B=[]
C=[]

for i in A:
    tmp=(i/2)
    if tmp%2!=0:
        B.append(i)
    else:
        C.append(i)
#print(B)        
q=lcm(*A)
#print(q)
if len(A)==len(B):
    if 2*M<q:
        print(0)
    elif (2*M//q)%2==0:
        print(2*M//(2*q))
    else:
        print(2*M//(2*q)+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import 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)
    
N,M=map(int,input().split())
A=set(map(int,input().split()))
cnt=0
B=[]
C=[]

for i in A:
    tmp=(i/2)
    if tmp%2!=0:
        B.append(i)
    else:
        C.append(i)
#print(B)        
q=lcm(*A)
#print(q)
if len(A)==len(B) or len(A)==len(C):
    if 2*M<q:
        print(0)
    elif (2*M//q)%2==0:
        print(2*M//(2*q))
    else:
        print(2*M//(2*q)+1)
else:
    print(0)

Submission status: Wrong Answer

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

max_a = max(a_list)

i = 1
X_list = []
while True:
    x = max_a * (i + 0.5)
    if x > M:
        break
    X_list.append(x)
    i += 1

check_list = []
for x in X_list:
    count = 0
    for a in a_list:
        if (x % a) / a != 0.5:
            break
        count += 1
    check_list.append(count)

print(check_list.count(len(a_list)))

Submission status: Wrong Answer

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

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

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

lcm = lcm_list(a)
for i in range(N-1):
    if a[i]//2 != a[i+1]//2:
        print(0)
        exit()
print((M+lcm//2)//lcm)

Submission status: Wrong Answer

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

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

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

lcm = lcm_list(a)
print((M+lcm//2)//lcm)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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


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

    semi_lcm = 1
    for a in A:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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


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

    semi_lcm = A[0]
    for a in A[1:]:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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


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


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

    semi_lcm = 1
    for a in A:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# x=a_i * (p+0.5)
# 前提としてaが偶数
# x= (a_i//2)*(2*p+1)
from fractions import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
koubai = A[0] // 2
for i in range(1, n):
    a = A[i]
    if a % 2 == 1:
        print(0)
        exit()
    a //= 2
    g = gcd(koubai, a)
    koubai *= a // g


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

Submission status: Wrong Answer

Solution code:
# x=a_i * (p+0.5)
# 前提としてaが偶数
# x= (a_i//2)*(2*p+1)
from fractions import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
koubai = A[0] // 2
for i in range(1, n):
    a = A[i]
    if a % 2 == 1:
        print(0)
        exit()
    a //= 2
    g = gcd(koubai, a)
    koubai *= a
    koubai //= g


if koubai > m:
    print(0)
    exit()
else:
    ans = (m // koubai + 1) // 2
    print(ans)

Submission status: Wrong Answer

Solution code:
# x=a_i * (p+0.5)
# 前提としてaが偶数
# x= (a_i//2)*(2*p+1)
from fractions import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
koubai = A[0]
for i in range(n):
    a = A[i]
    if a % 2 == 1:
        print(0)
        exit()
    a //= 2
    koubai += a
    g = gcd(koubai, a)
    koubai //= g


if koubai > m:
    print(0)
    exit()
else:
    ans = (m // koubai + 1) // 2
    print(ans)