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: Accepted

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

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

    # divisors.sort()
    return divisors
mdiv = make_divisors(m)
mdiv.sort()
#print(mdiv)

ans = m
for i in mdiv:
    if i >= n:
        ans = i
        break
print(m//ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
if N == 1:
    print(M)
    sys.exit()
ans = 1
for x in ls:
    if x >= N:
        ans = max(ans, M//x)
        continue
    if M//x >= N:
        ans = max(ans, x)
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
divs = []
for i in range(1, int(M**0.5)+1):
    if M%i==0:
        divs.append(i)
        divs.append(M//i)
print(max([d for d in divs if d*N<=M]))

Submission status: Accepted

Solution code:
import bisect

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

    # divisors.sort()
    return divisors



N,M= map(int,input().split(" "))
divs = make_divisors(M)
divs.sort(reverse=True)
d = M//N
for i in divs:
    if i <= d:
        print(i)
        exit()

Submission status: Accepted

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

def make_yakusuu(n):
  yakusuu=[]
  for i in range(1,int(n**0.5)+1):
    if n%i == 0:
      yakusuu.append(i)
      if i != n//i:
        yakusuu.append(n//i)      
  yakusuu.sort(reverse = True)
  return yakusuu

list=make_yakusuu(M)
A=list[0]
result=1
i=0
while(A>1):
  if (N<=M/A):
    result=A
    break
  else:
    i+=1
    A=list[i]
    
print(result)

Submission status: Accepted

Solution code:
## Nの正の公約数をリストで返す（ソートしたい場合は#外す）
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

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

lst = make_divisors(M)
for i in range(len(lst)):
  if M // lst[i] >= N:
    print(lst[i])
    exit()

Submission status: Accepted

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

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

if N==1:
    print(M)

else:
    div = sorted(make_divisors(M))
    i = 0 
    while i<=len(div) and M//div[i]>=N:
        ans = div[i]
        i+=1
    print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
def divisor(n): #約数全列挙
    ans = [1,n]
    i = 2
    while i**2 <= n:
        if n%i == 0:
            ans.append(i)
            if i**2 < n:
                ans.append(n//i)
        i += 1
    ans.sort()
    return ans

mlist=divisor(m)
ans = 0
for i in mlist:
    if n*i<=m:
        ans = max(ans,i)

print(ans)

Submission status: Accepted

Solution code:
def func(M):
    num = []
    for i in range(1, int(M**0.5)+1):
        if not M % i:
            num.append(i)
            num.append(M//i)

    num.sort()
    return num

N, M = list(map(int, input().split()))
ans = 1
x = M / N

num = func(M)

for n in num:
    if n <= x:
        ans = n
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
result = 1
i = 1
while i * i <= M:
    if M % i == 0:
        for d in [i, M // i]:
            if M // d >= N:
                result = max(result, d)
    i += 1
print(result)

Submission status: Accepted

Solution code:
def f(x):
    ret=[]
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            ret+=[i,x//i]
    ret.sort()
    return ret

N,M=map(int,input().split())
divitors=f(M)
for m in divitors:
    if m<N:pass
    else:
        print(int(M/m))
        break

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
mx = 0
for i in range(1, int(M**0.5)+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
        if i >= N:
            mx = max(mx, M//i)
print(mx)

Submission status: Accepted

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

Submission status: Accepted

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

div = []
for m in range(1, int(M ** (0.5) + 1)):
    if M % m == 0:
        div.append(m)
        if m != M // m:
            div.append(M // m)
            
div.sort()
for i in range(len(div)):
    if div[-i-1] * N <= M:
        print(div[-i-1])
        break

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0 and M // i >= N:
        mx = max(mx, i)
    if M % i == 0 and i >= N:
        mx = max(mx, M//i)
print(mx)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
mx = 0
for i in range(1, int(M**0.5)+1)[::-1]:
    if M % i == 0 and M // i >= N:
        mx = max(mx, i)
    if M % i == 0 and i >= N:
        mx = max(mx, M//i)
print(mx)

Submission status: Accepted

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

    # divisors.sort()
    return divisors

N, M = map(int, input().split())
ceil = M // N
divisors = make_divisors(M)
divisors.sort(reverse=True)
for i,j in divisors:
    if j >= N:
        print(i)
        break

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ceil = M // N
for i in range(1,ceil+1)[::-1]:
    tmp = M - i * (N - 1)
    if tmp > 0 and tmp % i == 0:
        print(i)
        break

Submission status: Accepted

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

d = []
i = 1
while i**2 < M:
    if M%i == 0:
        d.append(i)
        d.append(M//i)
    i += 1
if i**2 == M:
    d.append(i)
d.sort()

ans = 1
for i in range(len(d)):
    if d[i]*N <= M:
        ans = d[i]
print(ans)

Submission status: Accepted

Solution code:
def div(num):
  ret=[]
  for i in range(1,int(num**0.5)+1):
    if num%i==0:
      ret.append(i)
      if i!=num//i:
        ret.append(num//i)
  return ret

n,m=map(int,input().split())
div_list=div(m)
div_list=sorted(div_list,reverse=True)
ans=0
for i in div_list:
  if (m-i*n)%i==0 and m>=i*n:
    ans=i
    break
print(ans)

Submission status: Accepted

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

divisor_array = []
divisor_max = math.floor(math.sqrt(M))

for i in range(1, divisor_max + 1):
    if M % i == 0:
        divisor_array.append(i)
        divisor_array.append(M // i)

divisor_array.sort()

# print(divisor_array)
insert_index = bisect.bisect_left(divisor_array, N)

print(M // divisor_array[insert_index])

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
yakusuu=[]
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        yakusuu.append(i)
        yakusuu.append(M//i)

print(max([a for a in yakusuu if a*N<=M]))

Submission status: Accepted

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

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

divs = make_divisors(m)
d = [x for x in divs if x >= n][0]
print(m // d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n,m = map(int, input().split())
yakusu=[]
for i in range(1, int(math.sqrt(m))+1):
	if m % i == 0:
		yakusu.append(i)
		if i*i != m:
			yakusu.append(m//i)
			
ans=0
for i in yakusu:
	if m//i >= n:
		ans = max(i, ans)
		
print(ans)

Submission status: Accepted

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

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

    divisors.sort()
    return divisors

for i in make_divisors(M):
    if i <= M // N:
        ans = i 

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return

#D
def D():
    n, m = LI()
    ans = 1
    for i in range(1,int(math.sqrt(m)+1)):
        if m % i == 0:
            a = m // i
            #print(i,a)
            if a * n <= m:
                ans = max(ans, a)
            if i * n <= m:
                ans = max(ans, i)
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()

Submission status: Accepted

Solution code:
import math
def divisor(n):
    res = []
    for i in range(1,int(math.sqrt(n))+2):
        if n % i == 0:
            res.append(i)
            if n // i != i:
                res.append(n // i)
    return res
    
N, M = map(int, input().split())
maxd = 0
for d in divisor(M):
    if M // d >= N:
        maxd = max(maxd, d)
print(maxd)

Submission status: Accepted

Solution code:
import bisect
n,m=map(int,input().split())
l=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:l.extend([i,m//i])
l.sort()
print(l[bisect.bisect_right(l,m/n)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import math
N, M = map(int, input().split())
ans = 0
for a in range(1, int(math.sqrt(M))+1):
    if M % a != 0:
        continue
    b = int(M / a)
    if a * N <= M:
        ans = max(ans, a)
    if b * N <= M:
        ans = max(ans, b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0:
            j=0
            k=0
            if M//i>=N:
                j=i
            if i>=N:
                k=M//i
            ans = max(j,k,ans)

    print(ans)

Submission status: Accepted

Solution code:
# abcde    s=input()    s='abcde'
# abcde    s=list(input())    s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)    a=int(input())    a=5
# 1 2    | x,y = s_inpl()   |    x=1,y=2
# 1 2 3 4 5 ... n 　    li = input().split()    li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　    li = inpl()    li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　    li = input().split('T')    li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")
MAX_DIGIT = 50

############
############
############

N, M = l_inpl()

ans = 1

for k in range(1, int(M**0.5)+1):
    if k*N <= M:
        if M % k == 0:
            ans = max(ans, k)
            if k**2 == M:
                continue
            if (M//k)*N <= M:
                ans = max(ans, M//k)

print(ans)

Submission status: Accepted

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

if M % N == 0:    print(M//N)
elif M//N > 100000:
    for i in range(N,M//2+1):
        if M % i == 0:
            print(M//i)
            break
    else:
        print(1)
else:
    m = M//N
    for i in range(2,m)[::-1]:
        if M % i == 0:
            print(i)
            break
    else:
        print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import bisect
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int):
    ds = []
    for i in range(1, int(ceil(sqrt(M))) + 1):
        if M % i == 0:
            ds.append(i)
            ds.append(M // i)
    ds.sort()
  
    th = M // N
    return ds[bisect.bisect(ds, th)-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

import math

def divisor(M):
    divisor_list = []
    for num in range(1, math.ceil(math.sqrt(M)) + 1):
        if M % num == 0:
            divisor_list.append(num)
    return divisor_list
  
candidate = []
for num in divisor(M):
    M_k, M_sigmaB = num, M // num
    M_k2, M_sigmaB2 = M // num, num
    
    if M_sigmaB >= N:
        candidate.append(M_k)
    if M_sigmaB2 >= N:
        candidate.append(M_k2)
    
print(max(candidate))

Submission status: Accepted

Solution code:
from math import ceil, sqrt

N, M = map(int, input().split())
ans = 0
for i in range(1, ceil(sqrt(M))+1):
  if M % i==0:
    if i >= N:
      ans = max(ans, M//i)
    if M//i >= N:
      ans = max(ans, i)
      
print(ans)

Submission status: Accepted

Solution code:
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

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

ans = 0
i = 1
while i*i <= M:
    if M % i == 0:
        if i >= N:
            ans = max(ans, M // i)
        if M // i >= N:
            ans = max(ans, i)
    i += 1
print(ans)

Submission status: Accepted

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

if N==1:
  print(M)
  tmp=1
else:
  for i in range(int(M**0.8)+1):
    k = i + N
    if M % k == 0:
      print(int(M/k))
      tmp=1
      break

if tmp==0:
  print(1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
D - Partition
https://atcoder.jp/contests/abc112/tasks/abc112_d

"""
import sys


from bisect import bisect_right

def solve(N, M):
    def divisor(N):
        divisors = set()
        for i in range(1, int(N**0.5)+1):
            if N % i == 0:
                divisors.add(i)
                divisors.add(N // i)
        return divisors

    div_M = sorted(list(divisor(M)))
    i = bisect_right(div_M, M/N)
    if i:
        return div_M[i-1]
    else:
        return 1



def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

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

    divisors.sort()
    return divisors

def main():
    N, M = list(map(int, input().split()))
    k = M // N
    divisors = make_divisors(M)
    print([d for d in divisors if d <= k][-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
a_list = []
n, m = map(int, input().split())
for i in range(math.ceil(m**(1/2)), 0, -1):
    if m % i == 0:
        a_list.append(i)
        a_list.append(m//i)
border = math.floor(m / n)
a_list = list(reversed(sorted(a_list)))
for aa in a_list:
    if border >= aa:
        ans = aa
        break
print(ans)

Submission status: Accepted

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

    divisors.sort(reverse=True)
    return divisors


N, M = map(int, input().split())
for d in make_divisors(M):
    if d * N <= M:
        break
print(d)

Submission status: Accepted

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


import math
sM = int( math.sqrt(M) + 1 )

ma = 0
for i in range(1,sM):
  if (M%i)==0:
    a,b=i,M//i
    if ( a * N <= M ):
      ma = max(a,ma)
    if ( b * N <= M ):
      ma = max(b,ma)
print (ma)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n,m = li()

divs = divisors(m)
divs.sort(reverse=True)

ans = 1
for di in divs:
    if m // di >= n:
        ans = di
        break

print(ans)

Submission status: Accepted

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

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


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

    divisors.sort()
    return divisors


F = make_divisors(M)
gcd = 0

for i in range(len(F)):
    if F[i] * N > M:
        break

    gcd = F[i]

print(gcd)

Submission status: Accepted

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

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

    divisors.sort()
    return divisors

divisors = make_divisors(M)
for d in reversed(divisors):
    if M // d >= N:
        print(d)
        break

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)+1):
    if M%i == 0:
        a.append(i)
        a.append(int(M/i))
a.sort(reverse = True)
for i in a:
    if i <= M/N:
        print(i)
        break

Submission status: Accepted

Solution code:
import math

n,m = map(int,input().split())
ans = 0
for i in range(1,int(math.sqrt(m))+1):
    if m%i == 0 and i <= m/n:
        if ans < i:
            ans = i
    k = m//i
    if m%k == 0 and k <= m/n:
        if ans < k:
            ans = k

print(ans)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
# 範囲を絞る時は，反対の値も見るべき(M/iのこと)
print(max([j for i in range(int(M**0.5), 0, -1) for j in [i, int(M/i)] if M % j == 0 and M / N >= j]))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
divs = sorted(make_divisors(M),reverse=True)
for div in divs:
    if N <= M/div:
        print(div)
        break

Submission status: Accepted

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

N, M = map(int, input().split())
for i in reversed(div(M)):
    if i <= M//N:
        print(i)
        break

Submission status: Accepted

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

div = []
for i in range(1, int(M**0.5)+1):
  if M % i == 0:
    div.append(i)
    if M // i != i:
      div.append(M // i)
div.sort()

for i in range(len(div)):
  num = div[i]
  if num >= N:
    print(M // num)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divisor(x):
    ret = []
    i = 1
    while i*i <= x:
        if x%i == 0:
            ret.append(i)
            if x//i != i:
                ret.append(x//i)
        i += 1
    return sorted(ret, reverse=True)

n,m = map(int,input().split())
for g in divisor(m):
    if m//g >= n:
        print(g)
        break

Submission status: Accepted

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

N,M = [int(x) for x in input().split()]
divisor = make_divisors(M)
ans = 0
for x in divisor:
    if(x>=N):
        ans = M//x
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n, m = intin()

    divlist = get_divisors(m)
    divlist.sort()

    for div in divlist:
        if div >= n:
            print(m // div)
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def get_factors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def main():
    n, m = intin()

    flist = get_factors(m)
    flist.sort()

    for f in flist:
        if f >= n:
            print(m // f)
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def make_divisors(n):
    i, divisors = 1, []
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
        i += 1
    return divisors


ans = 0
for x in make_divisors(M):
    if N <= M // x:
        ans = max(ans, x)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


c = Counter(factorize(M))
a = [1]
for k, v in c.items():
    tmp = []
    for x in a:
        for i in range(v + 1):
            tmp.append(x * (k**i))
    a = list(set(a) | set(tmp))

ans = 0
for x in a:
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
divisors = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        divisors.append(i)
        if not i**2==m:
            divisors.append(m//i)
divisors.sort(reverse=True)
for i in divisors:
    if m//i>=n:
        print(i)
        break

Submission status: Accepted

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

ans = 1

for i in range(1, int(m ** 0.5)+1):
  if m % i == 0:
    if i >= n:
      ans = max(ans, m // i)
    elif m // i >= n:
      ans = max(ans, i)
      
      
print(ans)