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:
import fractions
N,M=map(int, input().split())
A = [int(a) for a in input().split()]
A2 = [a>>1 for a in A]

lcm = A2[0]
for i in range(1, N):
    lcm = lcm * A2[i] // fractions.gcd(lcm, A2[i])
    if lcm>M:
        print(0)
    exit()
    
B = sum([1 for a in A if lcm%a==0])
if B>0:
    print(0)
else:
    print((M//lcm+1)//2)

Submission status: Wrong Answer

Solution code:

def gcd(a, b):
    r = 0
    while True:
        if b > a:
            a, b = b, a
        r = a % b
        if r == 0:
            return b
        a = b
        b = r
def lcm(a, b):
    g = gcd(a, b)
    return (a // g) * b
res = 0
def func():
    global res
    N, M = [int(i) for i in input().split()]
    A = [int(i) // 2 for i in input().split()]

    for i in A:
        if i % 2 == 0:
            return
    n = A[0]
    for i in range(N - 1):
        n = lcm(n, A[i + 1])
    res = M // 2 // n
    if M >= 2 * n:
        res += 1
func()
print(res)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
def gcd(x1,x2):
    a=min(x1,x2)
    b=max(x1,x2)%a
    while not b==0:
        ta=b
        b=a%b
        a=ta
    return a

def lca(l):
    lc=1
    for i in range(len(l)):
       g=gcd(lc,l[i])
       lc=lc*l[i]//g
    return lc

end=False
for i in range(N):
    A[i]=A[i]//2
    if A[i]%2==0:
        end=True
        break
if end:
    print(0)
else:
    l=lca(A)
    ans=0
    m=M-l
    if m>=0:ans+=1
    ans+=(m//(l*2))
    print(ans)

Submission status: Wrong Answer

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

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

N,M=map(int,input().split())
A=list(map(int,input().split()))
LCM=lcm_list(A)//2
i=0
if M//LCM%2==1:
  r=1
else:
  r=0
print(M//LCM//2+r)

Submission status: Wrong Answer

Solution code:
def get_gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def get_lcm(a, b):
    return a * b // get_gcd(a, b)


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

B = A[0]

if sum([a % 2 != 0 for a in A]) > 0:
    print(0)
else:
    for b in A[1:]:
        pass
        # B = get_lcm(B, b)
    print(max(0, int((M + 0.5 * B) // B)))

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    b = [i >> 1 for i in a]
    l = b[0]
    for i in b[1:]:
        if l&1 != i&1:
            print(0)
            return
        g = gcd(l,i)
        l = l*i//g
        if l > m:
            print(0)
            return
    L = l
    l = 0
    r = m+1
    while r-l > 1:
        x = (l+r) >> 1
        if (2*x-1)*L <= m:
            l = x
        else:
            r = x
    print(l)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n, m = [int(_) for _ in input().split()]


def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if x > m:
            print(0)
            exit()
    return x


a = [int(_) // 2 for _ in input().split()]
l = lcm(a)
ans = m // l
if ans % 2 == 0:
    ans -= 1
print(ans // 2 + 1)

Submission status: Wrong Answer

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
d = defaultdict(int)

sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = list(set(A))

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

A_fac = [fctr1(val) for val in A]

max2 = max([val[0][1] for val in A_fac])

for vals in A_fac:
    for val in vals:
        if val[0] == 2: continue
        d[val[0]] = max(d[val[0]], val[1])

lcm = 1
lcm *= (2**max2)
for key, val in d.items():
    lcm *= (key**val)

div = M//lcm

if div + (lcm//2) <= M:
    print(div+1)
else:
    print(div)

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()]
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=lcm_list(a)
print((M+(l//2))//l)

Submission status: Wrong Answer

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

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

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

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

def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=list(map(calc_double,A))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """

    a=lcm_list(AA)
    #a=a//2
    """
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break
    """
    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:
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
    if k > M*2:
        print(0)
        exit(0)
    k = int(k)
ans = (M - (0.5*k)) // k
if M >= (0.5*k):
    ans += 1
print(int(ans))

Submission status: Wrong Answer

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

import numpy as np
import fractions
A=np.array(A)

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

num = lcm_list([v // 2 for v in A])
ans = M // num
if num % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + ans % 2)

Submission status: Wrong Answer

Solution code:
#!python3.4.3
from fractions import gcd

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

ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
if m//ans > 0:
    print((m//ans)+1)
else:
    print(0)

Submission status: Wrong Answer

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

scm=[]
for x in range(1,M+1):
    for _a in a: 
        p=x/int(_a)-0.5
        if not(p > 0 and p%1==0):
            break
    else:
        scm.append(x)
        if len(scm)>1:
            break
if len(scm)!=0:
    d=abs(scm[0]-scm[1])
    print(len(range(min(scm),M+1,d)))
else:
    print(0)

Submission status: Wrong Answer

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

n,m=map(int,input().split())
a=np.array(list(map(int,input().split())))
a=a//2
def lcm(x,y):
    return (x*y)//f.gcd(x,y)
def lcm_list(num):
    return reduce(lcm,num,1)
l=lcm_list(a)
if l%2==0:
    ans=0
else:
    ans=m//l

#奇数を取り除く
if ans%2==0:
    ans//=2
else:
    ans=ans//2+1
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(numbers):
    return reduce(lcm_base, numbers, 1)


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

L = lcm(A)

M = M * 2

a = int(M / (L*2))
b = int(M / L)
print(b-a)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m//gcd(n,m)

n,m = LI()
a = LI()
b = [i//2 for i in a]
if max(a) > m:
    print(0)
    quit()

for i in range(n):
    if b[i] % 2 == 0:
        print(0)
        quit()
if n == 1:
    lb = b[0]
else:
    lb = lcm(b[0],b[1])

for i in range(2,n):
    lb = lcm(lb,b[i])

if lb % 2 == 0:
    print(0)
    quit()

if lb > m:
    print(0)
    quit()

ans = m//lb//2 + (m // lb) %2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)

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

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

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

l = 1
for i in range(N):
  l = lcm(l, A[i])

M += l // 2

print(M//l)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = set(A)
power = 1
for b in B:
    power *= b//2

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Submission status: Wrong Answer

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

def f(num, max_val):
    r = []
    p = 0
    while True:
        x = num * (p+0.5)
        if x >= max_val:
            return r
        r.append(x)
        p += 1

al = []
for a_k in a_i:
    al += f(a_k, m)

print(len([x for x in set(al) if al.count(x) > (n-1)]))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

a = [x//2 for x in a]
if a[0] % 2 == 0:  # 偶数の時	
	print(0)
	sys.exit(0)
else:
	for x in a:
		if x % 2 == 0:
			print(0)
			sys.exit(0)
	tmp = 1
	for x in a:  # 奇数の時
		tmp = x*tmp//gcd(x, tmp)
	if tmp > M:
		print(0)
	else:
		print(ceil(M/(tmp*2)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

# A = list(set(A))

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

p = A[0]//2
q = A[0]
for i in range(1, N):
    # print(i)
    p = lcm(p, A[i]//2)
    q = lcm(q, A[i])
# print(p, q)

n = ((M - p) / q) + 1
print(int(n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
n = l1[0]
m = l1[1]

l2.sort(reverse = True)
count = 0

def lng(a,b):
    if(a%b != 0):
        return lng(b,a%b)
    else:
        return b
lng0 = l2[0]

for i in range(n):
    lng0 = (lng0*l2[i])//lng(lng0,l2[i])

ansm=0
for p in range(1000000000):
    x = l2[0]*(2*p+1)
    print(l2[0])
    if (x <= 2*m) & x <= lng0 :
        for k in range(n):
            if (x%l2[k]!=0) :
                break
            if k == n-1:
                ansm = x
        if ansm!=0:
            break
    else: 
        break

print (1 + (m-ansm//2) //lng0)

#& (x//l2[k]%2==1)

Submission status: Wrong Answer

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


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

baisu = A[0]
if A[0] % 2 == 1 or A[0] == 0:
    print(0)
    exit()

for i in range(1, len(A)):
    if A[i] % 2 == 1 or A[i] == 0:
        print(0)
        exit()
    baisu = baisu * A[i] // gcd(baisu, A[i])



# for a in A:
    # baisu = lcm(baisu, a)
# print(baisu)

b = baisu // 2
c = m // b + 1
d = c // 2
print(d)

Submission status: Wrong Answer

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

import sys
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()
A.sort()

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

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 numpy as np


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


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


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

M *= 2
for i, b in enumerate(a):
    if i == 0:
        v = b
    v = lcm(v, b)
    if v > M:
        print(0)
        exit()
print((M // v + 1) // 2)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=tuple(map(lambda x:int(x)//2,input().split()))
    g=a[0]
    b=g%2
    for x in a[1:]:
        if x%2!=b:
            print(0)
            exit()
        g=g*x//gcd(g,x)
    g*=2
    print((M+(g//2))//g)

        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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


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

t = b[0]
for x in b[1:]:
    t = lcm(t, x)

s = a[0]
for x in a[1:]:
    s = lcm(s, x)

ret = 0
if m >= t:
    m -= t
    ret += 1

    ret += m // s

print(ret)

Submission status: Wrong Answer

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

def euc(a,b):
    if b>a:
        return euc(b,a)
    c = a%b
    if c==0:
        return b
    return euc(b,c)

def common(a,b):
    #print(a,b)
    #print(euc(a,b))
    return a*b/euc(a,b)

def twodiv(x):
    count=0
    while x%2==0:
        x = x//2
        count+=1
    #print("count:",count)
    return count
  
  
def ans():
    #print(A)
    base = A[0]
    check = twodiv(A[0])
    for i in range(1,N):
        base = common(base,A[i])
        #print(base)
        if twodiv(A[i])!=check:
            #print(twodiv(A[i]))
            return 0
        if base > M :
            #print(base)
            return 0
    result = M//base
    
    #print(base,result)
    return int((result+1)//2)

print(ans())

Submission status: Wrong Answer

Solution code:
import fractions

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

A = list(set(A))

gcd = A[0]
for i in range(1, len(A)):
    gcd = gcd * A[i] // fractions.gcd(gcd, A[i])

half_gcd = gcd // 2

count = (M + half_gcd) // gcd

print(count)

Submission status: Wrong Answer

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

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

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

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

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] //= 2
G = gcd_list(A)
L = lcm_list(A)
# l = L // G
# print(G, L)
# ans = (M // l) // 2
# print(ans if ans == 0 else ans + 1)
print(ceil(M / L)//2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=len(A)
for i in range(n):
  A[i]=A[i]//2
def scn(a,b):
  s=min(a,b)
  l=max(a,b)
  c=1
  while True:
    if (l*c)%s==0:
      return l*c
    c+=1
def hscn(L):
  if len(L)==1:
    return L[0]
  else:
    L1=L[:len(L)//2]
    L2=L[len(L)//2:]
    return scn(hscn(L1),hscn(L2))
S=hscn(A)
n=M//S
if n%2==0:
  print(n//2)
else:
  print(n//2+1)

Submission status: Wrong Answer

Solution code:
def lcm(x, y):
    a = x
    b = y

    if (a > b):
        tmp = a
        a = b
        b = tmp

        tmp = x
        x = y
        y = tmp

    while (b % a != 0):
        tmp = b % a
        b = a
        a = tmp

    return ((x // a) * y)

n, m = list(map(int, input().split()))
a = []
ok = 0

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

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

lm = a[0]

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

cc = -1

for i in range(n):
    if (a[i] % 2 == 0):
        if (cc == -1):
            cc = a[i]
        elif (cc != a[i]):
            ok = 1
            break

if (ok == 1):
    print(0)
else:
    if (m - lm >= 0):
        ok = 1
        print(ok + ((m - lm) // (lm * 2)))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y):
    return (x * y) // gcd(x, y)
def gcd_list(numbers):
    return reduce(lcm, numbers)
N, M = map(int, input().split())
a = list(map(int, input().split()))
A = gcd_list(a)
a = list(map(lambda x:x//2, a))
B = gcd_list(a)
print(M//B-M//A)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

[v // 2 for v in A]
print(0)

Submission status: Wrong Answer

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

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

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

#co=1
endflag=0
#kai=0
for i in A:
    if i==2:
        endflag=1

num=A[0]//2
for i in range(1,len(A)):
    num=lcm(num,A[i]//2)
    
if endflag==1:
    print(0)
else:
    print(math.ceil(m//num/2))
#if num*2==max(A):
#    print(0)
#else:

Submission status: Wrong Answer

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

sys.setrecursionlimit(10000)

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


# def gcd(x, y):
#     while y != 0:
#         x, y = y, x % y
#     return x


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


def lcmm(l):
    return reduce(lcm, l)


x = lcmm(a)
# print(x)

i = m / x
ans1 = -(-m // x)  # 切り上げ
ans2 = m // x  # 切り捨て

if i >= ans2 + 0.5:
    print(ans1)
else:
    print(ans2)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
# 長さN
# 整数M
N, M = map(int, input().split())

# 長さNからなる偶数列: a
a = list(set(map(int, input().split())))
#print(a)

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)

result = M//(lcm_list(a))
#print(result)
if result == 0:
    print(0)
else:
    print(result+1)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

baisu = A[0]
if A[0] % 2 == 1:
    print(0)
    exit()

for i in range(1, len(A)):
    if A[i] % 2 == 1:
        print(0)
        exit()
    baisu = baisu * A[i] // gcd(baisu, A[i])



# for a in A:
    # baisu = lcm(baisu, a)
# print(baisu)

b = baisu // 2
c = m // b + 1
d = c // 2
print(d)

Submission status: Wrong Answer

Solution code:
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#data_url = "http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data"

#dataset = pd.read_csv(data_url, names=names)
# Save Iris dataset to a csv file
#dataset.to_csv('wine.csv', index=False)

dataset = pd.read_csv('./wine.csv')

names = ['class','Alcohol', 'Malic acid', 'Ash', 'Alcalinity of ash', 'Magnesium', 'Total phenols', 'Flavanoids', 'Nonflavanoid phenols', 'Proanthocyanins', 'Color intensity',
         'Hue', 'OD280/OD315 of diluted wines', 'Proline']

# See first 5 elements
print(dataset.head())

count = []
label = []
for i in range(3):
    count.append(len(dataset[dataset['class'].isin([i+1])]))
    label.append(i+1)

plt.pie(count, labels = label)
plt.show()

import math

#mse 계산 함수
def mse(ax, ay, bx, by):
    mse = 0
    tmpx = ax[:] #shallow copy
    tmpy = ay[:]
    n = len(bx)

    while len(tmpx):
        mn = -1
        mnidxa = -1
        mnidxb = -1

        for i in range(len(tmpx)):
            for j in range(i, len(bx)):
                tmp = math.sqrt((bx[j] - tmpx[i]) ** 2 + (by[j] - tmpy[i]) ** 2) #distance

                if mn == -1 or tmp < mn: #distance가 최소면
                    mn = tmp
                    mnidxa = i #a점 idx
                    mnidxb = j #b점 idx

        mse += mn #가장 가까운 두 점으로 계산

        del bx[mnidxb] #계산한 두 점은 제외
        del by[mnidxb]
        del tmpx[mnidxa]
        del tmpy[mnidxa]

    return mse / n

#여러 실험 결과로 나온 mse중 가장 mse값이 작은 것 찾기
def findBest(check):
    mn = -1
    mnidx = -1

    for i in range(len(check)):
        print(i + 1, "번째: ", check[i])

        if mnidx == -1 or check[i] < mn:
            mn = check[i]
            mnidx = i

    print(mnidx + 1, "번째: ", mn)

ax = [45, 26, 67, 15, 75 ,35, 70] #기존 자전거 배치
ay = [56, 20, 45, 14, 60, 20, 59]
bx = [29, 26, 86, 25, 56, 35, 32] #예측
by = [34, 36, 67, 16, 78, 24, 65]
cx = [15, 65, 65, 66, 26, 10, 47] #예측2
cy = [56, 24, 75, 85, 84, 20, 69]

mseCheck = []

mseCheck.append(mse(ax, ay, bx, by))
mseCheck.append(mse(ax, ay, cx, cy))

findBest(mseCheck)

#15.00315004 11
import math

a, b = list(map(float, input().split(' ')))
i = 0
t = a
c = a
zero = 0
zerocheck = 0
afzerocheck = 0

ok = str(t).find('.')
lent = len(str(t)) - ok - 1

print(str(t))

for j in range(lent):
    if zerocheck == 0 and math.floor(t) % 10 == 0:
        zero += 1
    else:
        zerocheck = 1

    if t - math.floor(t) > 0:
        i += 1
        t = t * 10

        if zerocheck == 1 and math.floor(t) % 10 == 0:
            afzerocheck += 1
    else:
        break

if i != 0:
    zerocheck = 0

print(lent, zero, c, pow(10, i))

b = int(b)
c = int(c * pow(10, i))

print(c)
c = str(c ** b)

if a < 1:
    for k in range(b * i - len(c) + 1):
        print(0, end='')

        if k == 0:
            print(".", end='')

    zerocheck = 1

print(c[0:len(c) - i * b], end='')

if zerocheck == 0:
    print('.', end='')

print(c[len(c) - i * b:len(c)])

print(c)
"""
def lcm(x, y):
    a = x
    b = y

    if (a > b):
        tmp = a
        a = b
        b = tmp

        tmp = x
        x = y
        y = tmp

    while (b % a != 0):
        tmp = b % a
        b = a
        a = tmp

    return ((x // a) * y)

n, m = list(map(int, input().split()))
a = []
ok = 0

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

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

lm = a[0]

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

cc = -1

for i in range(n):
    if (a[i] % 2 == 0):
        if (cc == -1):
            cc = a[i]
        elif (cc != a[i]):
            ok = 1
            break

if (ok == 1):
    print(0)
else:
    if (m - lm >= 0):
        ok = 1
        print(ok + ((m - lm) // (lm * 2)))
    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(numbers):
    return reduce(lcm_base, numbers, 1)
  
n, m = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0

full_lcm = lcm_list(a)

div = m // full_lcm
mod = (m % full_lcm) / full_lcm

if (mod < 0.5):
    print(div)
else:
    print(div+1)

Submission status: Wrong Answer

Solution code:
import sys
import fractions as fr
input = sys.stdin.readline

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

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

res = 1
for i in range(N):
    res = lcm(res,a[i])
    if res >= (10**10):
        print(0)
        exit()
if res%2==1 or res == 0:
    print(0)
    exit()
if M < res//2:
    print(0)
    exit()
k = ((2*M)//res + 1)//2
k = (M-res//2)//res+1
print(k)

Submission status: Wrong Answer

Solution code:
from math import ceil


def gcd(a, b):
    while b != 0:
        a, b = b, a - (a // b) * b

    return a


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

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

    return a


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

    lcm_b = lcm(B)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

aList = list(set(aList))
flag = False
count = 1

list1 = []
resList = []

for a in aList:
    while flag == False:
        sum = a * (count + 0.5)
        if sum <= m:
            list1.append(sum)
        else:
            flag = True
        count += 1
    
    if resList != []:
        resList = set(list1) & set(resList)
    else:
        resList = list1
    
    list1 = []
    count = 1
    flag = False

print(len(resList))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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


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

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

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

Submission status: Wrong Answer

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

def euc(a,b):
    if b>a:
        return euc(b,a)
    c = a%b
    if c==0:
        return b
    return euc(b,c)

def common(a,b):
    #print(a,b)
    #print(euc(a,b))
    return a*b/euc(a,b)

def twodiv(x):
    count=0
    while x%2==0:
        x = x//2
        count+=1
    #print("count:",count)
    return count
  
  
def ans():
    #print(A)
    base = A[0]
    check = twodiv(A[0])
    for i in range(1,N):
        base = common(base,A[i])
        #print(base)
        if twodiv(A[i])!=check:
            #print(twodiv(A[i]))
            return 0
        if base > M :
            #print(base)
            return 0
    result = M//base
    
    print(base,result)
    return int((result+1)//2)

print(ans())

Submission status: Wrong Answer

Solution code:
n, max_num = map(int, input().split())

num_list = list(map(int, input().split()))
ans_list = []

for i in range(len(num_list)):
    p = 0
    tmp_list = []
    while max_num > num_list[i]//2 * (2*p + 1):
        tmp_list.append(num_list[i]//2 * (2*p + 1))
        p += 1
   
    if i == 0:
       ans_list = tmp_list
    else:
       ans_list = list(set(ans_list) & set(tmp_list))
print(len(ans_list))