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

Submission status: Accepted

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

def factoring(n: int):
    factors = []
    p = 1
    while p * p <= n:
        if n % p == 0:
            factors.append(p)
            if n != p * p:
                factors.append(n // p)
        p += 1
    return factors

def solve(N: int, M: int):
    if N == 1:
        print(M)
        return
    F = factoring(M)
    F.sort()
    for f in F:
        if f >= N:
            print(M // f)
            break
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
from math import sqrt
d0=[]
for i in range(1,int(sqrt(m)+1)):
    if m%i==0:
        d0.append(i)
d=d0[:]
for di in reversed(d0):
    d.append(m//di)
for i in reversed(d):
    if i<=m//n:
        print(i)
        break

Submission status: Accepted

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

a = M // N

for i in range(a,0,-1):
    if M % i == 0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import math
n, m = map(int, input().split())
ans = 1
for k in range(1, math.ceil(math.sqrt(m))):
    l = m // k
    if m % k == 0 and n * k <= m:
        ans = max(k, ans)
    if m % l == 0 and n * l <= m:
        ans = max(l, ans)
print('%d' % ans)

Submission status: Accepted

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

while ans > 0:
    if m%ans == 0:
        if m//ans >= n:
            break
    else:
        ans -= 1

print(ans)

Submission status: Accepted

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

# Mの約数dのうち、Nd <= Mとなるものの最大

divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    if M%d == 0:
        divisors.append(d)
        divisors.append(M//d)

ans = 1

divisors.sort()

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
ans = 1
for i in range(1, int(math.sqrt(m)) + 2):
    if m % i == 0:
        if m // i >= n and i >= n:
            ans = max(ans, i, m // i)
        elif m // i >= n:
            ans = max(ans, i)
        elif i >= n:
            ans = max(ans, m // i)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from copy import deepcopy
from math import log

N,M=map(int,input().split())
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
f=prime_factor(M)
L=[1]
for i in f.keys():
    l=[]
    for j in range(f[i]+1):
        l.extend([k*(i**j) for k in L])
    L=l
L.sort()
for i in L[::-1]:
    if i>=N:
        ans=i
        continue
    break
print(M//ans)

Submission status: Accepted

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

if int(math.sqrt(M)) > N:
    divlist = []
    for i in range (N, int(math.sqrt(M))):
        if M%i == 0:
            divlist.append(i)
    
    if divlist != []:
        for i in range(N, int(math.sqrt(M))):
            if M%i == 0:
                ans = M//i
                break
    else:
        for i in range(N,0,-1):
            if M%i == 0:
                ans = i
                break
else:
    for i in range(M//N,0,-1):
        if M%i == 0:
            ans = i
            break
            
print(ans)

Submission status: Accepted

Solution code:
n, m = (int(i) for i in input().split())

a = m//n

for i in range(a):
    x = a-i
    if m % x == 0:
        print(x)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    N, M = map(int, input().split())
    yakusuu_list = []

    for i in range(1, int(M ** 0.5) + 1):
        if M % i == 0:
            yakusuu_list.append(i)
            yakusuu_list.append(M // i)
    yakusuu_list.sort(reverse=True)

    for num in yakusuu_list:
        if num * N <= M:
            print(num)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M=map(int,raw_input().split())
F=[]
i=1
while i * i <= M:
    if M%i==0:
        F.append(i)
        if i*i!=M: F.append(M/i)
    i+=1

F.sort()    
ans=-1
for k in F:
    if (M/k-N>=0):
        ans=k
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
def dv(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 sorted(divisors)

for i in dv(m):
    if i>=n:
        print(m//i)
        exit()

Submission status: Accepted

Solution code:

N, M = map(int, input().rstrip().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

print([i for i in make_divisors(M) if i <= M / N][-1])

Submission status: Accepted

Solution code:
import math

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


def get_divisors(n):
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


# m の約数を全列挙
divs = get_divisors(m)
divs.sort(reverse=True)

for d in divs:
    if d * n <= m:
        print(d)
        break

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split(' ')))
 
if M % N == 0:
	print(M//N)
	exit()

ans = 1
for i in range(2,100000+1):
	k = M % i
	if k == 0:
		j = M//i
		if i >= N and j >= N:
			ans = max(ans,i,j)
		elif i >= N:
			ans = max(ans,j)
		elif j >= N:
			ans = max(ans,i)
print(ans)

Submission status: Accepted

Solution code:
import math

n, m = map(int, input().split())
max_i = 1
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i != 0:
        continue
    j = m // i
    if i * n <= m and i > max_i:
        max_i = i
    if j * n <= m and j > max_i:
        max_i = j
print(max_i)

Submission status: Accepted

Solution code:
import bisect
import math
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    factor = set()
    for i in range(1, int(M**0.5)+1):
        if M % i == 0:
            factor.add(i)
    
    factor1 = set()
    for i in factor:
        factor1.add(M//i)
    factor |= factor1
    
    factor = sorted(list(factor))
    print(factor[bisect.bisect_right(factor, upper)-1])

Submission status: Accepted

Solution code:
from math import sqrt
N,M=map(int, input().split())
tmp=int(sqrt(M))
ma=1
for i in range(1, tmp+1):
    if not M % i:
        div = M//i
        ma = max(i if i*N <= M else 0, ma, div if div*N <= M else 0)
print(ma)

Submission status: Accepted

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


def solve(N: int, M: int):
    ret = 0
    i = 1
    while i * i <= M:
        if M % i == 0:
            if i >= N:
                ret = max(ret, M // i)
            if M // i >= N:
                ret = max(ret, i)
        i += 1
    print(ret)
    return


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
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solution():
    if N==1:
      return M
    
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())

Submission status: Accepted

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

def solution():
    answer = 1
    for i in range(1, int(M**0.5)+1):
        if M%i ==0:
            if M//i>=N:
                answer = max(answer , i)
            if i>=N:
                answer = max(answer, M//i)
    return answer

print(solution())

Submission status: Accepted

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

def solution():
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())

Submission status: Accepted

Solution code:
import math
def soinsu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(2,sqr+2):
        while N % i == 0:
            lis.append(i)
            N = N // i
    if not N == 1:
        lis.append(N)
    return lis

def yakusu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(1,sqr+2):
        if N % i == 0:
            lis.append(i)
            lis.append(N//i)
    return lis

mod = 1000000007
def modpow(a,b,MOD=mod):
    res = 1
    while b > 0:
        if (b & 1) == 1:
            res = (res*a) % MOD
        a = (a*a) % MOD
        b = b >> 1
    return res
fact = []
def ncrinit(MOD=mod):
    fact.append(1)
    for i in range(1,110005):
        fact.append((fact[i-1]*i)%MOD)

def calcnCr(n,r,MOD=mod):
    up = fact[n]
    down = modpow((fact[n-r]*fact[r])%mod,mod-2,mod)
    return (up*down)%mod

def compres(lis):
    li = []
    se = set(lis)
    for i in se:
        li.append(lis.count(i))
    return li
res = 1
N,M = list(map(int,input().split()))
co = yakusu(M)
co.sort()
for i in co:
    if M // i >= N:
        res = max(res,i)
print(res)

Submission status: Accepted

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

	total = m//n
	answer = 1
	for i in range(1, total+1):
		if i * i > m:
			break

		if m % i == 0:
			answer = max(i, answer)
			if i >= n:
				answer = max(m//i, answer)

	print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
x = 0
m = 0
for i in range(10**5):
    if i**2 < M <= (i+1)**2:
        m = i+1
        break
if m >N:
    for i in range(N, m):
        if M % i == 0:
            x = M // i
            break
if x == 0:
    for i in reversed(range(1, M //N +1)):
        if M % i == 0:
            x = i
            break
print(x)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
for i1 in range(1,int(m**0.5)+1):
    if m%i1==0:
        i2=m//i1
        if i1>=n:
            ans=i2
            break
        elif i2==n:
            ans=i1
            break
        elif i2<n:
            ans=pre_i1
            break
        pre_i1=i1
else:
    ans=pre_i1
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
f1=[]
f2=[]
for i1 in range(1,int(m**0.5)+1):
    if m%i1==0:
        i2=m//i1
        if i1>=n:
            ans=i2
            break
        elif i2==n:
            ans=i1
            break
        elif i2<n:
            ans=f1[-1]
            break
        f1+=[i1]
        f2+=[i2]
else:
    ans=f1[-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
 
def solve(x):
    if m % x == 0:
        return True
    else:
        return False
for i in range(m//n,-1,-1):
    if solve(i):
        print(i)
        exit()
    else:
        continue

Submission status: Accepted

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

n = 0
for i in range(1, int(math.sqrt(M))+1):
    if M < i * N:
        break

    if M % i == 0:
        n = max(i, n)
        if i >= N:
            n = max(M//i, n)

print(n)

Submission status: Accepted

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

Submission status: Accepted

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


ans=0

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:
def main():
    N, M = map(int, input().split())

    for g in range(M//N, 0, -1):
        if M % g == 0:
            print(g)
            return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    for i in range(N, int(M ** 0.5) + 1):
        if M % i == 0:
            return M // i
    for i in range(min(N - 1, int(M ** 0.5), M // N), 0, -1):
        if M % i == 0:
            return i
    return 1

print(main())

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
sqrtM = round(math.sqrt(M))+1

if N < sqrtM:
  for i in range(N,sqrtM+1):
    if M % i == 0:
      print(M//i)
      exit()
  for i in range(N-1,0,-1):
    if M % i == 0:
      print(i)
      exit()
else:
  for i in range(M//N,0,-1):
    if M % i == 0:
      print(i)
      exit()

Submission status: Accepted

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

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

print(str(ans))

Submission status: Accepted

Solution code:
def d_partition(N, M):
    def divisor_list(n):
        # n の正の約数のリスト
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.append(k)
                if k != n // k:
                    ret.append(n // k)
        return sorted(ret)
    # N = 1なら、a_1 = M とする他なく、これがGCD
    return max([d for d in divisor_list(M) if d <= M // N]) if N >= 2 else M

N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

Submission status: Accepted

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

if M//N < 10**7:
    for i in range(M//N,0,-1):
        if M % i ==0:
            break
    print(i)
else:
    for i in range(N,int(M**0.5)):
        if M % i == 0:
            break
    else:
        i = M
    print(M//i)

Submission status: Accepted

Solution code:
def gen_divisor(n):
    ps = []
    for i in range(1, int(1 + n ** 0.5)):
        if n % i == 0:
            yield i
            ps.append(n // i)
    if n // ps[-1] == ps[-1]:
        del ps[-1]
    for p in reversed(ps):
        yield p

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

def solve():
    for di in gen_divisor(M):
        if di >= N:
            ans = M // di
            return ans

print(solve())

Submission status: Accepted

Solution code:

def factorize(n):
    nn = n
    lst = []
    for i in range(2, int(1 + n ** 0.5)):
        k = 0
        while nn % i == 0:
            k += 1
            nn = nn // i
        if k > 0:
            lst.append([i, k])
    if nn != 1:
        lst.append([nn, 1])
    return lst

def gen_divisor(m):
    # not sorted!
    yield 1
    factorized = factorize(m)
    length = len(factorized)
    if length == 0:
        return
    factor_nexps = [0] * length
    while True:
        # increment
        factor_nexps[0] += 1
        for idx in range(length - 1):
            if factor_nexps[idx] > factorized[idx][1]:
                factor_nexps[idx] = 0
                factor_nexps[idx+1] += 1
        if factor_nexps[-1] > factorized[-1][1]:
            return
        divisor = 1
        for i, tup in enumerate(factorized):
            divisor *= tup[0] ** factor_nexps[i]
        yield divisor

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

def solve():
    divisors = sorted([di for di in gen_divisor(M) if di >= N])
    ans = M // divisors[0]
    return ans

print(solve())

Submission status: Accepted

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

ans = 1
for i in range(1, int(m**(0.5))):
    if m%i==0:
        d = m//i
        if d >= n:
            ans = i
            if i>=n:
                ans = d
                break
        else:
            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()
    return divisors

n,m=map(int,input().split())
l=make_divisors(m)
for i in l:
    if n<=i:
        ans=m//i
        break
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
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                if h > 0:
                    H = abs(x-cx)+abs(y-cy)+h
                    break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    def factorize(n):
        if n == 1:
            return [1]
        if n<4:
            return [1,n]
        l = [1,n]
        m = n
        z = 2
        while z**2 <= n:
            if m%z == 0:
                l.append(z)
                if m//z != z:
                    l.append(m//z)
            z += 1
        l = list(set(l))
        l.sort()
        return l

    n,m = LI()
    l = factorize(m)
    for i in l[::-1]:
        if n*i <= m:
            print(i)
            quit()

#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:
#abc112d

n,m=map(int,raw_input().split())
for i in xrange(m/n,0,-1):
 if m%i==0:
  print i
  break

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), long(input_raw[1])]

    ans = 0
    for i in range(1, int(math.sqrt(M)) + 2):
        if M % i == 0:
            j = M/i
            if M/i >= N:
                ans = max(ans, i)
            if M/j >= N:
                ans = max(ans, j)
    print ans




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
def getDivisor(inte):
    Ans1 = [1]
    Ans2 = [inte]
    for i in range(2,int(inte**(0.5))):
        if inte % i == 0:
            Ans1.append(i)
            Ans2.append(int(inte/i))
    if inte % inte**(0.5) == 0:
        Ans1.append(int(int(inte**(0.5))))
    Ans = Ans1 + Ans2[::-1]
    return Ans

limit = int(m/n)
for i in reversed(getDivisor(m)):
    if i <= limit:
        print(i)
        break

Submission status: Accepted

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

ans = 0
for i in range(1, int(math.sqrt(m))+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:
N, M = map(int, input().split())

if M % N == 0:
    ans = M // N
else:
    ans = 0
    for i in range(1, int(M ** 0.5) + 1):
        if M % i == 0:
            if i <= M // N:
                ans = max(ans, i)
            if M // i <= M // N:
                ans = max(ans, M // i)
        
print(ans)

Submission status: Accepted

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

if M % N == 0:
    ans = M // N
else:
    for i in range(1, M // N + 1):
        if M % i == 0:
            ans = i
            if M // i > i and M // i <= M // N:
                ans = M // i
                break
        
print(ans)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
# 問題はM//N>xを満たすようなMの約数xの中で最小のものと読み替えられる。
bdr = M//N
ans = 1

for i in range(1,int(M**0.5+1)):
    if M%i==0:
        yakusu = M//i
        if yakusu<=bdr:
            ans = yakusu
            break
        elif i <= bdr:
            ans = i
print(ans)

Submission status: Accepted

Solution code:
[print(max([i for j in [[i,a[1]//i] for i in range(1,int(a[1]**0.5)+1) if a[1]%i==0] for i in j if a[1]//i>=a[0]])) for a in [list(map(int,input().split()))]]

Submission status: Accepted

Solution code:
print((lambda a:max([i for j in [[i,a[1]//i] for i in range(1,int(a[1]**0.5)+1) if a[1]%i==0] for i in j if a[1]//i >= a[0]]))(list(map(int,input().split()))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,m=map(int, input().split())
c=[]
if n==1:
    print(m)
else:
    for i in range(1,math.floor(m**(1/2))+1):
        if m%i==0:
            c.append(i)
            c.append(m//i)
    c=sorted(c, reverse=True)
    for ci in c:
        if ci*n<=m:
            print(ci)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
for i in range(M//N + 1):
    if M % (M//N-i) == 0:
        print(M//N-i)
        quit()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    quit()
for i in range(M//N + 1):
    if M % (M//N-i) == 0:
        print(M//N-i)
        quit()

Submission status: Accepted

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

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)
        divisors.append(m//i)
divisors.sort()
k = 0
for i in range(len(divisors)):
    if divisors[i] > m/n:
        k = i - 1
        break
    if i == len(divisors) - 1:
        k = len(divisors) - 1
print(divisors[k])

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()
    divisors.reverse()
    return divisors

l=make_divisors(m)

for i in l:
    if i*n<=m:
        print(i)
        import sys
        sys.exit()

Submission status: Accepted

Solution code:
import math

n,m=map(int,input().split())
if n==1:
        print(m)
else:
        l=[]
        for i in range(1,math.floor(m**0.5)+1):
           if m%i==0 and i<=m//n:
                l.append(i)
                if m//i<=m//n:
                        l.append(m//i)
        l.sort()
        print(l[-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math


def GCD(a, b):
    # a < b
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def solve(N: int, M: int):
    # O(sqrt(M))
    yakusu = [i for i in range(1, int(math.sqrt(M))+1) if M % i == 0]
    yakusu.extend([M/y for y in yakusu[::-1]])

    ans = 0
    for y in yakusu:
        rest = M / y
        if rest >= N:
            # print(y, rest, N)
            ans = y

    print(int(ans))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
mm = math.floor(math.sqrt(M)) + 1
ans = 0
for a in range(mm, 0, -1):
  if M % a == 0:
    b = M // a
    if a >= N:
      ans = max(ans, b)
    elif b >= N:
      ans = max(ans, a)
print(ans)

Submission status: Accepted

Solution code:
# a1 + a2 + a3 ... + an = M
# ai の 最大公約数をDとする
# ai = xi * D　のはず。 D * x0 + D * x1 ... + D * xn = M
# まとめて D(x1 + x2 + .... + xn) = M
# 変形し、D = M / (x1 + x2 + .... + xn)
# (x1 + ... xn) = K とすると、Kを最小化するとDが最大化する
# M / K が割り切れる必要があるので、KはMの約数のいずれか
# K >= N。なぜなら xi >= 1 なので、Kは最低でも数字の個数 N になる
# つまり、約数のうちで N 以上の最初の値が K になる
# ex: 3 14
# 14 の約数 {1, 2, 7}
# K >= N なので、　K >= 3
# K = 7 で確定。つまり D = M/K = 2 でAnswer

N, M = map(int, input().split())
M_ROOT = int(M ** 0.5)
k = M
for i in range(1, M_ROOT + 1):
    if M % i == 0:
        if i >= N:
            print(M // i)
            exit()
        d = M // i
        if d < k and d >= N:
            k = d
print(M // k)

Submission status: Accepted

Solution code:
import math
N , M = map(int, input().split())
# 数列の和がＭ
# 数列の長さがＮ
# 最大でも、M ÷ Nが最大公約数ｘ
# (a1 + a2 +  )  = （b1 + b2 +  ）×　ｘ　＝　Ｍ
# M ÷ x = （b1 + b2 +  ） >= Ｎ
# M >= N × x 
# M ÷ N >= ｘ
# Ｍ　//　Ｎ >= ｘであるｘを大きい順に調べればよい？ ＹＥＳ
# 次に、ｘが条件を満たすかどうかを確認する
# 条件１：M ÷ ｘ は正の整数である
# 条件２：M ÷ ｘ >= Ｎ
lst = []
temp = int(math.sqrt(M) + 1)
for x in range(1 , temp):
    if (M % x == 0):
        lst.append(x)
        lst.append(int(M // x))
ans = 1
for d in lst:
    if M >=  (N * d):
        ans = max(ans , d)
print(ans)

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())

max_i = 0
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        if M//i >= N:
            max_i = max(max_i, i)
        if i >= N:
            max_i = max(max_i, M//i)
print(max_i)

Submission status: Accepted

Solution code:
import math


def divisors(n: int) -> list:
    s = int(math.sqrt(n))
    ret = []
    if s * s == n:
        ret.append(s)
    else:
        s += 1

    for i in range(1, s):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return sorted(ret, reverse=True)


def partition(N: int, M: int) -> int:
    for gcd in divisors(M):
        if gcd * N > M:
            continue
        return gcd
    return -1


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = partition(N, M)
    print(ans)

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

if M%N==0:
    print(M//N)
else:
    x = M//N
    ans = 1
    l=[]
    for i in range(1,int(M**0.5)+1):
        if M%i==0:
            l.append(i)
            l.append(M//i)
    l.sort()

    import bisect
    l_i = bisect.bisect_right(l,x)-1
    print(l[l_i])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
if m % n == 0:
    print(m//n)
    exit()
ret = 1
for d in reversed(range(2,100001)):
    while(m % d == 0):
        if m//d >= n:
            m //= d
            ret *= d
        else:
            break
print(ret)