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
import functools

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

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


n, m = map(int, input().split())
aset = set(map(int, input().split()))
amax = max(aset)


llcm = lcm(*aset)
minllcm = llcm // 2

ans = (m-minllcm) // llcm + 1
print(max(ans, 0))

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
    ok = []
    
    n = A[0]
    for i in range(N - 1):
        n = lcm(n, A[i + 1])
    if M // 2 < n:
        res = 1
    else:
        res = M // n // 2
        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()))

a.sort(reverse=True)
ans = [i for i in range(max(a)//2,(m + 1)//2)]

for j in a:
    if j % 2 == 1:
        break
    n_ans = []
    for i in ans:
        if ((i / j - 0.5) % 1 == 0):
            n_ans.append(i)
    ans = n_ans[:]

print(len(ans))

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd #なおす
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    while a[i] % 2 == 0:
        a[i] //= 2

g = a[0]
for i in range(n):
    g = (g*a[i])//gcd(g, a[i])
    if g > 3 * m:
        break
print(((m//g)+1)//2)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]
def gcdlist(a):
    from fractions import gcd
    if len(a) == 1:
        re = a[0]
    else:
        re = gcd(a[0],a[1])
        for i in range(2,len(a)):
            re = gcd(re,a[i])
    return re
                
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = x*a[i]
    return x // gcdlist(a)
flag = False
b = lcm(a)
while flag == False:
    flag = True
    for i in range(N):
        if (b // a[i]) % 2 == 0:
            flag = False
    if flag == False:
        b += b
if M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

halfa=[ai//2 for ai in a]

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

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

halfa_lcm=lcm_list(halfa)

for halfai in halfa:
    if((halfa_lcm//halfai)%2==0):
        print(0)
        sys.exit()

m_halfa_lcm=m/halfa_lcm
print(int(-(-m_halfa_lcm//2)))

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 - (k // 2)) // k

if M >= (k // 2):
    flag = True
    for i in range(N):
        if ((k // 2) // a[i]) > 0 and ((k // 2) // a[i]) % 2 == 0:
            flag = False
            break
    if flag:
        ans += 1

print(int(ans))

Submission status: Wrong Answer

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


if ans2>m:
    print(0)
else:
    print((m-ans2)//ans+1)

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 lmc>m:
        print("0")
        exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Submission status: Wrong Answer

Solution code:

import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M, *A = map(int, read().split())

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

if f_ == 0:
    cnt = 0
else:
    cnt = M // f_ - M // (f_*2)
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

print(A//2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


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 = inpl()
aa = inpl()
tmp = aa[0]//2
for a in aa[1:]:
    tmp = lcm(a//2,tmp)
    if tmp > M:
        print(0)
        sys.exit()


print(M//tmp - M//(tmp*2))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from sys import stdin
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    lcm = lambda x, y: x * y // gcd(x, y)
    x = reduce(lcm, A)
    for i in A:
        n = x // i
        if not n % 2:
            print(0)
            return
    print((M + x + 1) // x)


main()

Submission status: Wrong Answer

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

b=set([(i//2)%2 for i in a])
c=set([i//2 for i in a])
if 0 in b:
    print(0)
    exit()

    
import fractions as fr
from functools import reduce

def gcd(*numbers):
    return reduce(fr.gcd, numbers)

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

kk=1
for i in list(c):
  kk*=i
low=(kk)//gcd_list(list(c))


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

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]
def gcdlist(a):
    from fractions import gcd
    if len(a) == 1:
        re = a[0]
    else:
        re = gcd(a[0],a[1])
        for i in range(2,len(a)):
            re = gcd(re,a[i])
    return re
                
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = a[i]
    return x // gcdlist(a)
flag = False
b = lcm(a)
while flag == False:
    flag = True
    for i in range(N):
        if (b // a[i]) % 2 == 0:
            flag = False
    if flag == False:
        b += b
if M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [ai // 2 for ai in a]
b.sort(reverse = True)
LCM = b[0]
for bi in b:
    LCM = LCM * bi // fractions.gcd(LCM, bi)
if LCM % 2:
    print(((m // LCM) + 1) // 2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

a2 = [0]*N
min_ai = min(a)
for i in range(N):
    a2[i] = 0.5*a[i]
    if a[i]%2 != 0:
        print(0)
        break
    if (a2[i]-min_ai//2) %2 != 0:
        print(0)
        break
else:
    tmp = 1
    for a2i in a2:
        tmp = lcm(tmp,a2i)
    ans = int((M//tmp)//2+1)

    print(int((M//tmp)//2+1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
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

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 fractions import gcd

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

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

l = lcm(ai) // 2
i = m // l
if i == 0:
    print(0)
    exit()
if i == 1:
    print(1)
    exit()
if i % 2 == 1:
    ans = int(bin(i)[:-1], 2) + 1
else:
    ans = int(bin(i)[:-1], 2)

print(ans)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

from fractions import gcd
f = True
bs = 1
for i in range(n):
    b = a[i] // 2
    g2 = gcd(b, bs)

    c1 = b // g2
    c2 = bs // g2

    if c1 % 2 == 0 or c2 % 2 == 0:
        f = False
        break

    bs = bs * b // g2

    if bs > m:
        f = False
        break

if not f:
    print(0)
else:
    mmax = (m - bs) // (2 * bs)
    print(mmax + 1)

Submission status: Wrong Answer

Solution code:
N, M = [int(n) for n in input().split()]
B = [int(n) // 2 for n in input().split()]
m = max(B)

count = 0
for i in range(M // m):
    j = (i + 1) * m
    f = True
    for k in range(N):
        if j <= B[k]:
            f = False
            break
        if j % B[k] != 0:
            f = False
            break
        pp1 = j // B[k]
        if pp1 % 2 == 0:
            f = False
            break
    if f:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import math

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

def factorization(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

p = set()

flag = 0



ans = 0
tmp = factorization(A[0])
tmp2 = tmp[0][1]
for i in range(N):
    tmp = factorization(A[i])
    if tmp[0][1] != tmp2:
        flag = 1
        break
    for t in tmp:
        p = p | {pow(t[0], i) for i in range(1,t[1]+1) }
q = 1
pp = list(p)
for i in range(len(pp)):
    q *= pp[i]

if flag==0:
    minans = 1
    maxans = M
    cnt = 0
    i = M  //2
    while(cnt < 30):
        cnt += 1
        if q * (i * 2 + 1) // 2 > M :
            maxans = i
            i -= (maxans-minans) // 2
        else:
            minans = i
            i += (maxans-minans) // 2

    for j in range(4):

        if q*((i-2+j)*2 + 1) // 2 <= M:
            ans = (i-2+j)+1
        

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import functools

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

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


n, m = map(int, input().split())
aset = set(map(int, input().split()))
amax = max(aset)


llcm = lcm(*aset)
minllcm = llcm // 2

ans = (m-minllcm) // llcm + 1
print(max(ans, 0))

Submission status: Wrong Answer

Solution code:
input1 = input().split()
n = int(input1[0])
m = int(input1[1])
list_p = input().split()
count = 0
i = 1
for i in range(int(m/2)):
  check = True
  for j in range(n):
    if(i * 2/int(list_p[j]) % 0.5 != 0):
      check = False
      break
  if(check):
    count = count + 1
print(int(count))

Submission status: Wrong Answer

Solution code:
import sys
import fractions
bbn=1000000007
	
#+++++

def gcd(a,b):
	return fractions.gcd(a,b)
	
def lem(a,b):
	return (a*b)//gcd(a,b)
		
def main():
	n, m = map(int, input().split())
	al=list(map(int, input().split()))
	ii=al[0]//2
	ll=ii
	for v in al[1:]:
		ll=lem(ll,v//2)
		
	if ll%2==0:
		return 0
		
	ret=((m//ll)+1)//2
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

def lcm(nums):
		return reduce(multiple, nums)
	
n,m=map(int,input().split())
a=list(map(int,input().split()))

ans=lcm(a)
print(m*2//ans-m*2//(ans*2))

Submission status: Wrong Answer

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

def gcd(a, b): #a,bの最大公約数
    while b:
        a, b = b, a % b
    return a
def lcm(a, b): #a,bの最小公倍数
    return a * b // gcd (a, b)

A = list(set(A)) 

# すべての数の最小公倍数
all_lcm = 1
for a in A:
  all_lcm = lcm(all_lcm, a)
  
# 条件式を満たす最大の少数p
plist = [(M/a - 0.5) for a in A]

if all_lcm > M:
  print(0)
elif min(plist) < 1:
  # 条件を満たす整数Xが存在しないAがある場合は個数0
  print(0)
else:
  # print(plist)
  # plist = [int(p) for p in plist]  # それぞれこの個数分ある
  print(int((M)/all_lcm - 0.5)+1)
  # print(all_lcm)
  # print(plist)

Submission status: Wrong Answer

Solution code:
import fractions


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

    l = a2N[0]
    for i in range(1, N):
        l = l * a2N[i] // fractions.gcd(l, a2N[i])
        if M < l:
            l = 9999999999999999999
            break

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


main()

Submission status: Wrong Answer

Solution code:
#D - Semi Common Multiple
import math
# N=3
# M=50
# a = [6,10,18]

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

b=[]
for j in range(N):
    b.append([])
    x = 0
    p = 0
    while x < M:
        x = a[j]*(p+0.5)
        p = p + 1
        if x.is_integer():
            b[j].append(int(x))

c=[]
for j in range(N):
    c.append(set(b[j]))

d=c[0]
for j in range(N-1):
    d = d&c[j+1]

print(len(d))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y):
    return (x // gcd(x, y))*y
def gcd_list(numbers):
    res = 1
    for n in numbers:
        res = lcm(n, res)
        if res>M:
            return -1
    return res


N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = max(a)
A = gcd_list(a)
a = list(map(lambda x:x//2, a))
B = gcd_list(a)
a, b = M//A, M//B
if A == -1:
    a = 0
if B == -1:
    b = 0
print(b-b//2)

Submission status: Wrong Answer

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


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


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


def main():
    N, M = map(int, input().split())
    numbers = set(map(int, input().split()))
    numbers = np.array(list(numbers))
    numbers = numbers // 2

    lcm = lcm_list(numbers)

    print(((M+1) // lcm + 1) // 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()))

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

c = 0
num = b
while True:
  if num < M * 2 :
    result = True
    for i in range(N):
      if (num / a[i]) % 2 == 0:
        result = False
        break
    if result:
      c += 1
  else:
    break
  num += b
print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N,M=map(int,input().split())
A=list(map(int,input().split()))
import fractions
from functools import reduce
def lcd_base(X,Y):
    return (X*Y)//fractions.gcd(X,Y)
def lcd(*numbers):
    return reduce(lcd_base,numbers,1)

gcd_number=lcd(*A)//2
temp_ans=M//gcd_number
if temp_ans%2==0:
    print(temp_ans//2+1)
else:
    print(temp_ans//2+1)

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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

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

n, m = map(int, input().split())
a_list = sorted(set(map(int, input().split())))
prod = 1
for a in a_list:
    prod *= a // 2
if len(a_list) == 1:
     print((m - prod) // a_list[0] + 1)
     exit(0)
lcm = lcm_list(a_list)
if prod > m:
    print(0)
else:
    print((m - prod) // lcm + 1)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % (i + 0.5) == 0:
            divisors.append(i + 0.5)
            if i + 0.5 != n // (i + 0.5):
                divisors.append(n//(i + 0.5))

    # divisors.sort()
    return divisors


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

A = []
# それぞれの割り切れる奴リストを作成。
for j in range(N):
    an = make_divisors(a[j])
    A.append(an)

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

print(len(get_unique_list(A)))

Submission status: Wrong Answer

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

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

def LCM(arr, n): 
    res = arr[0]
    for i in range(1, n):
        res = lcm(res, arr[i])
  
    return res; 
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
AH = [a//2 for a in A]

D = LCM(A, N)
O = D // 2

if (M == O):
    print(1)
elif (M > O):
    print((M-O) // D + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def nankai2(n):
  result = 0
  for i in range(100000):
    n, mod = divmod(n, 2)
    if mod == 0:
      result += 1
    else:
      return result

import fractions

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

ans = a2[0]
for i in range(1, len(a2)):
    ans = ans * a2[i] // fractions.gcd(ans, a2[i])
print(ans)
result = 0
i = 1

q, mod = divmod(m, ans)
q = q * 2 * nankai2(ans/2)
q2, mod2 = divmod(q, 2)

if mod2 == 0:
  print(int(q2))

else:
  print(int(q2 + 1))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from sys import stdin
input = stdin.readline
from fractions import gcd
from math import ceil

def main():
    _,M = map(int,input().split())
    A = tuple(int(i)//2 for i in input().split())

    MAXA = max(A)
    if M < MAXA:
        print(0)
        exit()

    MINX = reduce(lcm, A) * 2

    ok = 0
    ng = M+1
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if MINX <= mid*MINX <= M:
            ok = mid
        else:
            ng = mid
    if ok == 0:
        print(ok)
    else:
        print(ng)

def lcm(x, y):
        return (x * y) // gcd(x, y)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

B = []
for x in A:
    if x not in B:
        B.append(x)

if A != B:
    A = B
    N = len(A)

c = 0
for j in range(N):
    a = A[j]
    print(j, a)
    for i in range(M):
        if (i+1) * (j+1 + 0.5) == a:
            c = c + 1
print(c)

Submission status: Wrong Answer

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

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

def f(x, y):
    return int((x / y + 1) // 2)

def main():
    N,M = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = np.array(a)
    
    m = A // 2
    X_min = np.max(m) * 3
    lcm = reduce(lcm_base, m, 1)
    #print(lcm)
    
    if f(M, lcm) == 0:
        print(0)
        exit()

    if N == 1:
        print(f(M, lcm) - f(X_min, lcm) + 1)
        exit()
    
    print(f(M, lcm))



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

ans=[]
a,b=A[0],0
p=0
while b<=M:
    b=a*p+a/2
    ans.append(int(b))
    p+=1

for a in A:
    p=0
    b=0
    temp=[]
    while b<=M:
        b=a*p+a/2
        temp.append(int(b))
        p+=1
    ans=list(set(ans)&set(temp))

print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a_list = {i for i in map(int, input().split())}
a_lcmp2 = 1
for a in a_list:
  a_lcmp2 *= a//2
print(M//( a_lcmp2*((max(a_list)+(a_lcmp2-1))//a_lcmp2)) )

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, m, *a = map(int, open(0).read().split())
lcm = 1
for x in a:
	x //= 2
	g = gcd(lcm, x)
	if (lcm // g) % 2 != (x // g) % 2:
		print(0)
		exit()
	lcm = lcm * x // g
print(m // (2 * lcm) + (m % (2 * lcm) >= lcm))

Submission status: Wrong Answer

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

from fractions import gcd
g = 1
for a in A:
  a //= 2
  g = a*g//gcd(a,g)

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
#from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
    #N = int(input())
    N,M = map(int, input().split())
    #vP = tuple(map(int, input().split()))
    vA = set(map(int, input().split()))
    #vA = list(range(1,N+1))

    l = 1
    for a in vA:
        l = lcm(l,a)
        if l>M:
            print(0); return
    #print(l, file=sys.stderr)
    #l //= 2
    print(((M//(l//2))+1)//2)
    #print(abs(p-q))
    #S = input().rstrip()
    #print(S)
    #print(lcm(N, M))
    #print("Yes" if X<=500*K else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

tmp = 0
ans = 0
cnt = 0
cnt_2 = 0
flag = 1

while True:
  tmp = a[0] * (cnt + 0.5)
  if tmp > M:
    break
  else:
    for i in range(1, N):
      if flag == 1:
        while True:
          if tmp == a[i] * (cnt_2 + 0.5):
            break
          elif tmp < a[i] * (cnt_2 + 0.5):
            flag = 0
            break
          else:
            cnt_2 += 1
      else:
        break
    if flag == 1:
      ans += 1
  cnt += 1
  flag = 1
print(ans)

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))
n,m = words(int)
xs = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

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

lcms = 1
plus = xs[0]//2
ans = True
for x in xs:
    if plus % 2 != (x//2)%2:
        ans = False
        break
    lcms = lcm(lcms,x)
    plus = lcm(plus, x//2)

#print(lcms,plus)
if ans:
    print((m + plus) // (lcms))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,M = LMIIS()
    A = list(set(map(lambda x: int(x)//2 ,input().split())))
    # print(A)
    from fractions import gcd
    g = A[0]
    for i in A[1:]:
        g = gcd(g,i)
    


    f = A[0] % 2
    for i in A:
        if i % 2 != f:
            print(0)
            return
    lcm = 1
    for i in A:
        lcm *= i
    lcm //= g
    #print(lcm,(M-lcm) // (lcm*2))

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
for x in range(max(A)//2, M, 2):
    for a in A:
        p = (x-(a/2))/a
        if p < 0 or p%1 != 0:
            break
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

ans = lcm(list(set(A)))//2

if ans > m:
    print(0)
else:
    print((m-ans)//(ans*2)+1)

Submission status: Wrong Answer

Solution code:
import functools


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


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


def multiple(a, b):
    return a*b // euclid(a, b)


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A2)
cnt = 0
if lcm % 2 == 0:
    print(cnt)
else:
    if 0 < lcm <= m:
        num = m // lcm
        if num % 2 == 1:
            cnt = (num + 1) // 2
        else:
            cnt = num // 2
    print(cnt)

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)
    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:
import fractions
n, m = map(int, input().split())
a = list(set(list(map(int, input().split()))))
ans = a[0] / 2
torf = "f"
for i in range(1, len(a)):
    ans = ans * a[i]/2 // fractions.gcd(ans, a[i]/2)
for j in range(len(a)):
    if a[j]/2 % 2 == 0:
        print(int(m//ans))
        torf = "t"
        break
if torf == "f":
    print(int(m//ans - (m//(ans*2))))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import math
print(math.floor(m/max(a)-0.5)+1)

Submission status: Wrong Answer

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

ans=0
n,m=map(int,input().split())
a=list(map(int,input().split()))
lcm=a[0]//2
flag=0
f=1
if(lcm&1):
	flag=1
for i in range(n):
	if(flag^((a[i]//2)&1)):
		f=0
		break
	lcm=((a[i]//2)*lcm)//(gcd(a[i]//2,lcm))
	if(lcm>m):
		f=0
		break
if(f):
	if(lcm&1):
		ans=(m//(2*lcm))+1
	else:
		ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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


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

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

Submission status: Wrong Answer

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

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n, m = map(int, input().split())
A = list(map(lambda x: int(x)//2, input().split()))
g = gcd_list(A)
A = np.array(A)
A //= g
A = A.tolist()
l = lcm_list(A)
if l%2 == 0:
  print(0)
else:
  print(((m//l*g)+1)//2)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = tuple(map(int, input().split()))[::-1]
lst=[]
for ele in A:
    p=0
    X = ele*(p+0.5)
    while X < M:
        X = ele*(p+0.5)
        lst.append(X)
        p+=1
u = [x for x in lst if lst.count(x)==N]
print(len(u))

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 - (k // 2)) // k

if M >= (k // 2):
    flag = True
    for i in range(N):
        if (k // a[i]) % 2 == 0:
            flag = False
            break
    if flag:
        ans += 1

print(int(ans))