Problem:


Score : 400 points

Problem Statement

You are given integers N and M.

Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.

Sample Input 1

3 14

Sample Output 1

2

Consider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000



Sample input:
3 14


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math

N, M = [int(_) for _ in input().split()]


sr = int(math.sqrt(M))

result = 1

for i in range(sr, 0, -1):
    if M % i == 0:
        r = i
        if M >= N * r:
            result = max(r, result)
        r = M / i
        if i >= N:
            result = max(r, result)

print(result)

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
maxlim = 10**5
for j in range(n,maxlim+1):
    if m%j == 0:
        minj = j
        break
k = m//j
print(k)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[0] == 1:
	ans = n[1]
else:	
#	prime = []
#	i = 2
#	m = n[1]
#	while i*i <= m:
#		while m%i ==0:
#			m /= i
#			prime.append(i)
#		i += 1
#	if m > 1:
#		prime.append(m)
	
	i=2
	while i <= n[1]//n[0]:
		if n[1]%i ==0:
			ans = i
		i+=1
	
#	for i in range(2,(n[1]+1)//2):
#		if n[1]%i == 0 and i*n[0] <= n[1]:
#			ans = i
		
	

print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
if b%a == 0:
    print(b//a)
else:
    print(b%a)

Submission status: Wrong Answer

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

i = 1
ans = 0
while True:
    if i * i > M + 1:
        break
    j = M // N
    if M % i == 0 and M // i >= N:
        ans = max(ans, i)
    if M % j == 0 and M // j >= N:
        ans = max(ans, j)
    i += 1
    

print(ans)

Submission status: Wrong Answer

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

def canMake(div):
    return (M%div == 0) and (M//div) - (N-1) >= 1

ans = 1
for i in range(1, M):
    if i * i > M:
        break
    if M % i != 0:
        continue
    a, b = i, M/i
    if canMake(a):
        ans = max(ans, a)
    if canMake(b):
        ans = max(ans, b)
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if m%n==0:
    print(m//n)
else:
    index=1
    while index <m:
        if m%index==0:
            if index > n-1:
                print(m//index)
                break
        index+=1

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
a=1
b=0
while b==0:
    for i in range(int(m**0.5)+1,1,-1):
        if m%i==0 and m>=(i*n):
            a*=i
            m=m//i
            break
    else:b=1
print(a)

Submission status: Wrong Answer

Solution code:
iN,iM = [int(_) for _ in input().split()]
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a


if iM % iN == 0:
    print(iM // iN)
else:
    iJ = iM % iN
    iD = iM // iN
    print(fgcd(iD * 2 , iD + iJ))

Submission status: Wrong Answer

Solution code:
iN,iM = [int(_) for _ in input().split()]
iD = iM // iN
if iM % iN == 0:
    print(iD)
else:
    for i in range( iD , 0,-1):
        if iM % i == 0:
            print(i)

Submission status: Wrong Answer

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

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , int(iM ** 0.5)+1):
        if iM % i == 0:
            aRet.append( i )
            if iM // i < iM//iN:
                aRet.append(iM // i)
    print( max(aRet) )

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
res = 1
for i in range(1, min(num+1, int(math.sqrt(M)))):
    if M % i == 0:
        res = i
print(res)

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N > 1:
    num = min(num, int(math.sqrt(M+1)))
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N ==1:
    print(M)
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N > 1:
    num = min(num, int(math.sqrt(M)))
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N > 1:
    num = max(num, int(math.sqrt(M)))
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
num = min(num, int(math.sqrt(M)))
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = 1
for i in range(1, int(m ** .5) + 1):
    if m % i == 0:
        b = m // i
        if i * n <= m:
            ans = max(ans, i)
        if b * n <= m:
            ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(" "))
K = M//N

if N < K:
    i = N
    while True:
        if M % i == 0:
            print (M//i)
            break
        i += 1 + (1 & i)
else:
    i = K
    while True:
        if M % i == 0:
            print (i)
            break
        i -= 1 + (1 & i)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(n, int(m ** .5) + 1):
    if m % i == 0:
        print(m // i)
        exit()

Submission status: Wrong Answer

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

ans = 1
tmp = 2
max_divisor = int(M ** 0.5)
max_ans = M // N
while tmp <= M:
    if M % tmp == 0 and tmp <= max_ans:
        ans = tmp

    if tmp > max_divisor and tmp != M:
        tmp = M
    else:
        tmp += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
N,M = map(int,input().split())
 
ans = 1
for i in range(1,int(math.sqrt(M))+1+1):
  if M % i != 0:#約数ではないとき
    continue
  B = M / i
  
  if (i * N <= M):
    ans = max(ans,i)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
N,M = map(int,input().split())
 
ans = 1
for i in range(1,int(math.sqrt(M)+1)+1):
  if M % i != 0:#約数ではないとき
    continue
  B = M / i
  
  if (i * N <= M):
    ans = max(ans,i)
  if (B * N <= M):
    ans = max(ans,B)
 
print(ans)

Submission status: Wrong Answer

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

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = set()
ins.add(1)
for k, v in insu.items():
    tmp = 1
    for _ in range(v):
        tmp *= k
        if tmp > max_ans:
            break
        for s in list(ins):
            ans = s * tmp
            if ans > max_ans:
                continue
            ins.add(ans)
        ins.add(1)

print(max(ins))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
n, m = map(int, input().split())

M = set()
for i in range(1, ceil(sqrt(m))):
    if m % i == 0:
        M.add(i)
        M.add(m//i)
M = sorted(list(M), reverse=True)
#print(M)
for i in M:
    if i <= m // n:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

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

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
#    if (m/i)*n<=m:
#      ans=max(ans,m/i)
print(int(ans))

Submission status: Wrong Answer

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

res = 1
for i in range(1, N + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if long(i) * N <= M:
		res = max(res, i)
	if long(j) * N <= M:
		res = max(res, j)
print res

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
for i in range(m//n+1,1)[::-1]:
  if m%i==0:
    print(i)
    break

Submission status: Wrong Answer

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

res = 1
for i in range(1, N + 1):
	if i > M * M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
for i in range(m//n,1,-1):
  if m%i==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import math

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

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if (m/i)*n<=m:
      ans=max(ans,m/i)
print(ans)

Submission status: Wrong Answer

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

res = 1
for i in range(1, N + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
for i in range(m//n,1):
  if m%i==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import sys
import math
Input = sys.stdin.readline
 
N, M = map(int, Input().split())
 
D = [d for d in range(1, int(math.sqrt(M))+1) if M % d == 0]
D.sort(reverse=True)
for d in D:
    if M >= N*d:
        print(d)
        sys.exit()

Submission status: Wrong Answer

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

msq = int(math.sqrt(M)) + 100
if N == 1:
    ans = M
else:
    for i in range(msq, 0, -1):
        if M%i == 0:
            tmp = M - (i*(N-1))
            if tmp > 0 and tmp%i == 0:
                ans = i
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

x=int(math.floor(math.sqrt(m)))

y=int(math.floor(m/n))

ans=1
for i in range(1,x+1):
  if(m % i==0):
    if i <= y:
      ans=max(ans,i)
    if (int(m/i)) <= y:
      ans=max(ans,m/i)
print(ans)

Submission status: Wrong Answer

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

res = 0
for i in range(1, N + 1):
	if i > M * M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Wrong Answer

Solution code:
import sys
import math
Input = sys.stdin.readline
 
N, M = map(int, Input().split())
 
for i in range(int(math.sqrt(M))+1, 0, -1):
    if M % i == 0:
        if M >= N*i:
            print(i)
            sys.exit()

Submission status: Wrong Answer

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

res = 0
for i in range(1, N + 1):
	if i > M * M:
		break
	if M % i != 0:
		continue
	if i * N <= M:
		res = max(res, i)
print res

Submission status: Wrong Answer

Solution code:
import math

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

x=math.floor(math.sqrt(m))

y=math.floor(m/n)

ans=1
for i in range(1,x+1):
  if(m % i==0):
    if i <= y:
      ans=max(ans,i)
    if m/i <= y:
      ans=max(ans,m/i)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
                m.append(T//i)
    print (m[-1])
if T % N == 0:
    print (int(N / T))
else:
    ans()

Submission status: Wrong Answer

Solution code:
import math
N,M=(int(i) for i in input().split())
ans=1
for i in range(1,int(math.sqrt(M))+1):
	if M%i == 0:
		if i*N <=M:
			ans=max(ans,i)
		if (M/i)*N <=M:
			ans=max(ans,M/i)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

# ans = []
# for i in L[::-1]:
#     if (M - (N * i)) % i == 0:
#     # if M % i == 0:
#         ans.append(i)
# print(max(ans))

ans2 = 1
for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans2 = i
        break
print(ans2)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

def divEnum(num):
    hoge = []
    for i in range(1,num):
        if num % i == 0:
            hoge.append(i)
    return hoge

divs = divEnum(m)
#print(divs)

ans = 0
for fact in divs:
    if(m / fact >=  n):
        ans = fact
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
Input = sys.stdin.readline
 
N, M = map(int, Input().split())
 
for i in range(int(math.sqrt(M))+1, 1, -1):
    if M % i == 0:
        if M >= N*i:
            print(i)
            sys.exit()

Submission status: Wrong Answer

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

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , min(iM // iN + 1 ,int(iM ** 0.5)+1)):
        if iM % i == 0:
            aRet.append( i )
    print( max(aRet) )

Submission status: Wrong Answer

Solution code:
import math

# N, M = map(int, input().split())

N = 100000
M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []
for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans.append(i)
print(max(ans))

# ans2 = 1
# for i in L[::-1]:
#     if (M - (N * i)) % i == 0:
#     # if M % i == 0:
#         ans2 = i
#         break
# print(ans2)

Submission status: Wrong Answer

Solution code:
import math
N,M=(int(i) for i in input().split())
ans=0
for i in range(1,int(math.sqrt(M))+1):
	if M%i == 0:
		if i*N <=M:
			ans=max(ans,i)
		if (M/i)*N <=M:
			ans=max(ans,M/i)
print(ans)

Submission status: Wrong Answer

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

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , int(iM ** 0.5)+2):
        if iM % i == 0:
            if iN * i < iM:
                aRet.append( i )
    print( max(aRet) )

Submission status: Wrong Answer

Solution code:
import math

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

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

for i in L[::-1]:
    # if (M - (N * i)) % i == 0:
    if M % i == 0:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M)) + 1
if N == 1:
    ans = M
else:
    for i in range(MAX_SQRT, 0, -1):
        if M%i == 0:
            tmp = M - (i*(N-1))
            if tmp > 0 and tmp%i == 0:
                ans = i
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import math


def solve(N, M):
    if N == 1:
        return M
    ans = [1]
    MAX = math.ceil(math.sqrt(M))
    for D in range(2, M // N + 1):
        if M >= N * D and M % D == 0:
            ans.append(D)
        if D > MAX + 1:
            break
    return max(ans)


if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
import math

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

# N = 100000
# M = 1000000000

# def get_div_list(num):
#     if num == 1:
#         return [1]
#     else:
#         div_list = []
#         div_list.append(1)
#         div_list.append(num)
#         for i in range(2, math.floor(math.sqrt(num))+ 1):
#             if num % i == 0:
#                 div_list.append(i)
#                 div_list.append(num // i)
#         list(set(div_list))
#         return div_list

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]
# print(L)




for i in L[::-1]:
    if (M - (N * i)) % i == 0:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M)) + 1
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0:
        tmp = M - (i*(N-1))
        if tmp > 0 and tmp%i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def solve(N, M):
    ans = [1]
    MAX = math.ceil(math.sqrt(M)) + 1
    for D in range(2, M // N + 1):
        if M >= N * D and M % D == 0:
            ans.append(D)
        if D > MAX:
            break
    return max(ans)


if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
import math

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

# N = 100000
# M = 1000000000

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list


L = get_div_list(M)
L = [i for i in L if i * N <= M]
# print(L)


for i in L[::-1]:
    if (M - (N * i)) % i == 0:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0:
        tmp = M - (i*(N-1))
        if tmp > 0 and tmp%i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

# N, M = map(int, input().split())

N = 100000
M = 1000000000

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list


L = get_div_list(M)
L = [i for i in L if i * N <= M]
# print(L)


for i in L[::-1]:
    if (M - (N * i)) % i == 0:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , int(iM ** 0.5)+2):
        if iM % i == 0:
            aRet.append( i )
    print( max(aRet) )

Submission status: Wrong Answer

Solution code:
import math

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

x=math.floor(math.sqrt(m))

y=math.floor(m/n)

ans=1
for i in range(1,x+1):
  if i <= y:
    if(m % i==0):
      ans=i
  else:
    break    
print(ans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0:
        tmp = M-(i*(N-1))
        if tmp > 0 and tmp%i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

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

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , int(iM ** 0.5)+2):
        if iM % i == 0:
            aRet.append( i )
    print( aRet[-1] )

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
a=1
for i in range(1,int(math.sqrt(m))+1):
 if m%i==0:
  if i*n<=m:
   kotae=max(a, i)
  if (m//i)*n<=m:
   kotae=max(a, m//i)
print(a)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[]
for i in range(1,int(m**2)+1):
    if m%i==0 and i<=n:
        s.append(i)
        if m/i<=n:
           s.append(m/i)
print(max(s))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=int(min(m/n,m**0.5+1))
for i in range(a,0,-1):
    if m%i==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

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

# N = 3
# M = 14

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]

for i in L[::-1]:
    if (M - (N * i)) % i == 0:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from math import *


def solve(N, M):
    def fact(M):
        return [i for i in range(1, ceil(sqrt(M)) + 1) if M % i == 0]
    return max([m for m in fact(M) if m <= M // N  and M >= N * m])

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
import math

N,M=(int(i) for i in input().split())
yakusu=[]
ans=0

for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        yakusu.append(i)
        yakusu.append(M//i)

for i in yakusu:
	if M%i == 0:
		ans=max(i,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N,T  = map(int,input().split())
p =[]
if T % N == 0:
    print (int(T / N))
    exit()

d = int(T / N)
for i in range(d+1,1,-1):    
    if T % i ==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
from math import sqrt
from math import ceil
N,M = map(int,input().split())

ans = 1

if N == 1:
    print(M)
    exit()
 

for i in range(2,ceil(sqrt(M))+1):

    temp = M

    temp -= i * (N)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

Solution code:
N,T  = map(int,input().split())
p =[]
if T % N == 0:
    print (int(T / N))
    exit()

d = int(T / N)
for i in range(d,1,-1):    
    if T % i ==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def solve(N, M):
    def fact(M):
        ans = []
        for i in range(1, int(pow(M, 0.5)) + 2):
            if M % i == 0:
                ans.append(i)
        return ans

    return max([m for m in fact(M) if m <= M // N + 1])

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
def solve(N, M):
    def fact(M):
        ans = []
        for i in range(1, int(pow(M, 0.5)) + 2):
            if M % i == 0:
                ans.append(i)
        return ans

    can = [m for m in fact(M) if m <= M // N + 1]
    print(can)
    return max(can)

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Wrong Answer

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

i = 1
ans = 0
while True:
    if i * i > M:
        break
    j = M // N
    if M % i == 0 and M / i >= N:
        ans = max(ans, i)
    if M % j == 0 and M // j >= N:
        ans = max(ans, j)
    i += 1
    

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m/i)*n<=m:
			kotae=max(kotae, m/i)
print(kotae)

Submission status: Wrong Answer

Solution code:
import math

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

# N = 3
# M = 14

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]
# print(L)

ans = L[-1]

print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=int(min(m/n,m**0.5))
for i in range(a,0,-1):
    if m%i==0:
        print(i)
        break

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0:
        if i <= M//N:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

Solution code:

def fact(M, m):
    ans = []
    for i in range(2, m + 1):
        if M % i == 0:
            ans.append(i)
    return ans


def solve(N, M):
    ans = [1]
    F = fact(M, max(int(pow(M, 0.5)), M // N))
    for D in F:
        if M >= N * D and M % D == 0:
            ans.append(D)
    return max(ans)

Submission status: Wrong Answer

Solution code:
import math

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

# N = 3
# M = 14

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]
print(L)

ans = L[-1]

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m/i)*n<=m:
			kotae=max(kotae, i)
print(kotae)

Submission status: Wrong Answer

Solution code:
import math
N,T  = map(int,input().split())
 
if T % N == 0:
    print (int(T / N))
    exit()
    
for i in range(2,T):    
    A = math.ceil(T / N)
    #print(A)
#    print(A)
    if T % i ==0:
        print(i)
        break
    N = A

Submission status: Wrong Answer

Solution code:
import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

print(ans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0:
        if M//i >= N:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

# print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
import math
s = math.sqrt(M)
sq = math.floor(s)
l = [i for i in range(1,sq) if M%i == 0]
if len(l) == 1:
    l.append(M)
ans = 1
for r in l:
    n = M//r
    if n >= N:
        ans = max(ans,r)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding : utf-8

import math

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

b = M//N

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M/i)

ans = 1
for l_ in l:
    if l_*N <= M:
        ans = max(ans,l_)

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(1, int(m**0.5)+1)[::-1]:
    if i<=m//n and m%i==0:
        if m//i<=m//n:
            print(m//i)
        else:
            print(i)
        break

Submission status: Wrong Answer

Solution code:
# coding : utf-8

import math

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

b = M//N

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)

ans = 1
for l_ in l:
    if l_*N <= M:
        ans = max(ans,l_)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

# amax = M // N
L = get_div_list(M)
# L = [i for i in L if i <= amax]

# ans = L[-1]

# print(ans)

Submission status: Wrong Answer

Solution code:
# coding : utf-8

import math

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

b = M//N

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M/i)

ans = 1
for l_ in l:
    if l_ <= b:
        ans = max(ans,l_)

print(ans)

Submission status: Wrong Answer

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

V_MAX = int(M ** 0.5)

ans = 1
for k in range(2, V_MAX + 1):
    div, mod = divmod(M, k)
    if mod == 0:
        if M >= N * k:
            ans = max(ans, k)
        if M >= N * div:
            ans = max(ans, div)

print(ans)

Submission status: Wrong Answer

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

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d+1,0,-1):
    	if M%i == 0:
    		print(d)
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Wrong Answer

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

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

# amax = M // N
L = make_divisor_list(M)
# L = [i for i in L if i <= amax]

# ans = L[-1]

# print(ans)