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())
for i in range(m//n, 0, -1):
    if m%i == 0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう→しなかった(コーナーケースに助けられた？)
# 2 999999937でTLEしてしまうのでこれは嘘解答

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

# 以下嘘解答
# ans = M // N
# for a in range(ans, 0, -1):
#     if M % a == 0:
# print(a)
# exit()

# 本当の解答
ans_temp = M // N
if M % N == 0:
    print(ans_temp)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))

    if arr == []:
        arr.append((n, 1))

    return arr


def make_divisors(n, sort=False):
    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)
    if sort:
        divisors.sort()
    return divisors


print(max(make_divisors(M), key=lambda x: 0 if x > ans_temp else x))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLE思想

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

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

Submission status: Accepted

Solution code:
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    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


divs = get_divisors(M)
# M の約数を N 以上繰り返した数列を作って、N 番目より後ろの要素をどっかに加算する
divs.sort(reverse=True)
for d in divs:
    if M // d >= N:
        print(d)
        break

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    S = M
    q = 0
    while S > M // N:
      S = M // X[q]
      if S <= M // N:
        break
      q += 1
      if q == len(X):
        break
    if q == len(X):
      S = max(X)
print(S)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
x = 2
res = 0
if N == 1: 
  print(M)
  exit(0)
while x * x <= M:
  if M % x == 0:
    if M // x >= N: res = max(res, x)
    y = M // x
    if M // y >= N: res = max(res, y)
  x += 1
if res == 0: print(1)
else: print(res)

Submission status: Accepted

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

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

ans = 1
for i in sorted(divisors(M)):
  if i >= N:
    ans = M//i
    break
print(ans)

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)

# print(d)
ans = 1

for div in d:
    if div * n <= m:
        ans = max(ans, div)

print(ans)

Submission status: Accepted

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

import math
sq=int(math.sqrt(m))//1

#計算量減らすために、予め約数のリスト用意。
yaku=[]
for i in range(1,sq+1):
  if m%i==0:
    yaku.append(i)
    yaku.append(m//i)
yaku.sort(reverse=True)

for i in yaku:
  if n*i<=m:
    print(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)

    divisors.sort(reverse=True)
    return divisors
for i in range(len(make_divisors(m))):
  if make_divisors(m)[i]<=(m//n):
    break
print(make_divisors(m)[i])

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

divisors = make_divisors(M)
divisors.sort()

for idx, a in enumerate(divisors):
    # print(a)
    if M / a >= N:
        continue
    else:
        if idx-1 < 0:
            print(1)
            exit()
        else:
            print(divisors[idx-1])
            exit()
        break
       
print(divisors[-1])

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def divisors(N: int) -> set:
    """ 約数の列挙・個数 """
    from math import sqrt

    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N, M = MAP()

# 約数列挙
divs = sorted(divisors(M), reverse=1)
# 約数を大きい方から見ていって、N個以上作れるならそれが最善
for div in divs:
    cnt = M // div
    if cnt >= N:
        print(div)
        exit()

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())
divs = make_divisors(M)
for d in divs:
    m = M // d
    if m >= N:
        ans = d
        break
print(d)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import fractions
input = sys.stdin.readline
N, M  = [int(x) for x 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
ans = make_divisors(M)
ans = sorted(ans)[::-1]
for i in ans:
    if i <= M/N:
        print(i)
        sys.exit()

Submission status: Accepted

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

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

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

    if M % N == 0:
        return print(M//N)

    divs = [i for i in trial_division(M) if i >= N]
    print(M//min(divs))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
    return divisors


# 素因数分解
def prime_factorization(n):
    fact=[]
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            fact.append(i)
    return fact

def main():
    N,M= MI()
    P = find_divisor(M)
    ans = 1
    for p in P:
        if M/p>=N:
            ans = max(ans,p)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# N, D, K = map(int,input().split())
# LR = [list(map(int,input().split())) for _ in range(D)]
# ST = [list(map(int,input().split())) for _ in range(K)]

from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res

N, M = map(int,input().split())
cand = divisor(M)
ans = 1
for ch in cand:
    if M // ch >= N:
        ans = max(ans, ch)

print(ans)

Submission status: Accepted

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = True
show_flg = False


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def eucledean(A, N):
    # A = sorted(A)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(A[i], ans)
    print(ans)


def main():
    N, M = MI()
    data = sorted(divisor(M))
    ans = 1

    for i in data:
        c = M // i
        # print(i, c)
        if c >= N:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

            if i ** 2 == n:
                continue
            ass.append(n // i)
    return ass

def main():
    N, M = map(int, input().split())
    d = divisor(M)
    d.sort(reverse=True)
    for i in d:
        if i * N <= M:
            print(i)
            exit()




if __name__ == "__main__":
    main()

Submission status: Accepted

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


n, m = map(int,input().split())
k = (m+1) // n

div = calc_divisor(m)
for i in div:
    if i <= k:
        ans = i
print(ans)

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:
        e=m//i
        d.append(i)
        d.append(e)
ans=0

for i in d:
    if m>=n*i:
        ans=max(ans,i)

print(ans)

Submission status: Accepted

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


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


d = div(m)
ans = 0
for x, y in d:
    if y >= n:
        ans = max(ans, x)

print(ans)

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)
dd=list(set(d))
dd.sort()
for x in dd:
  if x>=N:
    print(M//x)
    break

Submission status: Accepted

Solution code:
import bisect

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

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

divisors = make_divisors(M)
idx = bisect.bisect_right(divisors,int(M/N)) - 1
print(divisors[idx])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

def divider(m):
  i = 1
  s = deque()
  g = deque()
  while i**2 < m:
    if m % i == 0:
      s.append(i)
      g.appendleft(m//i)
    i += 1
  if i**2 == m:
    s.append(i)
  s += g
  return s
        

N, M = map(int, input().split())
D = divider(M)
ans = 0
for d in D:
  if d*N <= M:
    ans = d
  else:
    break
print(ans)

Submission status: Accepted

Solution code:
import math

n,m = map(int,input().split())
roop = min(m//n,math.floor(math.sqrt(m)))
if n == 1:
    print(m)
    exit()
ans = -10**9
for i in range(1,roop+1):
    if m%i == 0:
        if m//i <= m//n:
            ans = max(ans,i,m//i)
        else:
            ans = max(ans,i)
print(ans)

Submission status: Accepted

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = 1
n = 1
while n*n <= M:
    if M % n == 0:
        if M//n >= N:
            ans = max(n, ans)
        m = M//n
        if M//m >= N:
            ans = max(m, ans)
    n += 1
print(ans)

Submission status: Accepted

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

N, M = map(int, input().strip().split())
ans = 1
if N == 1:
    print(M)
    exit()

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

print(ans)

Submission status: Accepted

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


## 約数の列挙O(N)
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def solve(N: int, M: int):
    if M%N == 0:
        print(M//N)
        return

    max_answer = M//N
    divisors = divisor(M)
    divisors.sort()

    index = bisect_left(divisors,max_answer)
    if index == 0:
        print(1)
        return 
    print(divisors[index-1])


    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:
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())
divisors_list = make_divisors(M)
divisors_list.sort(reverse=True)
#print(divisors_list)
for val in divisors_list:
    if val * N <= M:
        break
print(val)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def main():
    N, M = map(int, input().split())
    s = M // N  # 答えはs以下
    m = M % N

    for i in range(s, 0, -1):
        if m % i == 0:
            print(i)
            sys.exit()
        else:
            m += N


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor


def solve(n, m):
    factor = [1]
    if m % n == 0:
        ans = m // n
    else:
        for f in range(floor(m//n), 1,-1):
            if m % f == 0:
                factor.append(f)
                break
        ans = factor[-1]

    return ans


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve(n, m))

Submission status: Accepted

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

ans = 1
for i in range(m//n,0,-1):
    rest = m - (i * (n - 1))
    if rest % i == 0:
        print(i)
        sys.exit()

Submission status: Accepted

Solution code:
import bisect
n,m=map(int,input().split())
l=[]
for i in range(1,int(m**(1/2))+1):
    if m%i==0:
        l.append(i)
        if i!=m//i:
            l.append(m//i)
l.sort()
z=bisect.bisect_left(l,n)
print(m//l[z])

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

div_max = m//n + 1
divs = sorted(make_divisors(m))
from bisect import bisect_left

ind = bisect_left(divs, div_max)
print(divs[ind-1])

Submission status: Accepted

Solution code:
#Partition
import math
N,M = map(int,input().split())
n = 1
rootM = int(math.sqrt(M))+1
for i in range(rootM):
    if M % (i+1) == 0 and N*(i+1) <= M:
        if N*(M/(i+1)) <= M and n <= (M/(i+1)):
            n = M/(i+1)
        elif n <= i+1:
            n = i+1
        else:
            continue
print(int(n))

Submission status: Accepted

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

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

divs = divisors(m)
ans = 1
for d in divs:
    if m // d >= n:
        ans = d
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    n,m=map(int,input().split())
    D=divisors(m)
    ans=0
    for d in D:
        if(d*n<=m):
            ans=max(d,ans)
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import bisect
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
line = make_divisors(m)
print(m//line[bisect.bisect_left(line, n)])

Submission status: Accepted

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

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

d = divisor(M)

for i in d:
  if M//i >= N:
    print(i)
    break

Submission status: Accepted

Solution code:
def divide(x): #約数配列
    div=[1]
    check=2
    for check in range(1,int(x**0.5)+1):
        if(x%check==0):
            div.append(check)
            div.append(x//check)
    div.sort()
    return div

def main():
    n,m = map(int,input().split())
    di=divide(m)
    for i in range(len(di)):
        if di[len(di)-1-i]<=m//n:
            print(di[len(di)-1-i])
            return
    
if __name__ == "__main__":
    main()

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

import bisect
def find_lt(a,x):
    i = bisect.bisect_right(a,x)
    if i:
        return a[i-1]
    else:
        return -1

MD=make_divisors(M)
print(find_lt(MD,M//N))

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=1)
    return divisors

n,m = map(int,input().split())
y = make_divisors(m)
for i in y:
  if m // i >= n:
    print(i)
    exit()

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())
L = make_divisors(M)
for l in L:
    if M // l >= N:
        print(l)
        exit()
print(1)

Submission status: Accepted

Solution code:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
d = 1
if (N == 1):
    print(M)
else:
    while (d*d <= M):
        if (M//d * d != M): 
            d += 1
            continue
        d2 = M//d
        if (d*N <= M):
            ans = max(ans, d)
        if (d2*N <= M):
            ans = max(ans, d2)
        d += 1
    print(ans)

Submission status: Accepted

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

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

for i in reversed(range(1, M // N + 1)):
	if M % i == 0:
		print(i)
		break

Submission status: Accepted

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

def solve() :
    ret = 1
    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
    
    return ret

print(solve())

Submission status: Accepted

Solution code:
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

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

x = min(M//N, int(M**0.5))
ans_list = []

while x > 0:
    if M % x == 0:
        ans_list.append(x)
        if (M//x) * N <= M:
            ans_list.append(M//x)
    x -= 1
    
print(max(ans_list))

Submission status: Accepted

Solution code:
import sys
import math

#+++++


		
def main():
	n,m = map(int, input().split())
	if m % n ==0:
		return m // n
		
	ll=1
	for i in range(1, int(math.sqrt(m))+1):
		#pa((i,ll))
		if m % i == 0:
			if i >= n:
				ll=max(ll, m // i)
			if m // i >= n:
				ll=max(ll, i)
	return ll
				

#+++++
isTest=False

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

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

Submission status: Accepted

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

for i in y:
    if i <= tmp:
        ansMax = i
    else:
        break
print(ansMax)

Submission status: Accepted

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

def compute_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 = compute_divisors(M)
divs.sort(reverse=True)

for div in divs:
    if M / div >= N:
        ans = div
        break

print(ans)

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 divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=sorted(divisor(m))
for i in d[::-1]:
  if m//i>=n:print(i);break

Submission status: Accepted

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

def get_divisors(num):
    f_divs, l_divs = [], []
    for i in range(1, int(num**0.5)+1):
        if not num % i:
            f_divs.append(i)
            if i != num // i:
                l_divs.append(num // i)
    return f_divs + l_divs[::-1]

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

Submission status: Accepted

Solution code:
#全ての約数を列挙。o(√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() 

    return divisors

n,m = [int(_) for _ in input().split()]
ans = 0
l = make_divisors(m)
for i in range(0, len(l)):
    if m // l[i] >= n:
        ans = max(l[i], ans)
print(ans)

Submission status: Accepted

Solution code:
def div(N):
    ans = []


    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans

N,M=map(int,input().split())
if N==1:
    print(M)
    exit()

divM=div(M)

for i in range(1,len(divM)):
    if divM[i]>M//N:
        print(divM[i-1])
        exit()

Submission status: Accepted

Solution code:
import  fractions
import math
import bisect
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

ans=0
cnt=make_divisors(M)
tmp=bisect.bisect_right(cnt,M/N)

print(cnt[tmp-1])

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if N==1:
    print(M)
    exit()

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

Submission status: Accepted

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

def get_divisor(n):
    '''nの約数を返す
    '''
    d = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.add(i)
            d.add(n//i)
    return d

D = list(get_divisor(M))
D.sort(reverse=True)

ans = 0
for d in D:
    if M//d < N:
        continue
    ans = d
    break

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
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
divisors_m = list(reversed(sorted(make_divisors(m))))
D = list(filter(lambda x:x <= m/n, divisors_m))
print(max(D))

Submission status: Accepted

Solution code:
import bisect

N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5)+2):
    if M%i==0:
        d.append(i)
        d.append(M//i)
d.sort()
ind=bisect.bisect_right(d,M//N)
print(d[ind-1])