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 sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    m_sqrt = int(math.sqrt(M)) + 2

    ans = set()
    for i in range(1, m_sqrt):
        if M % i == 0:
            if M // i >= N:
                ans.add(i)
            if i >= N:
                ans.add(M // i)
    print(max(ans))
            
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 = make_divisors(M)
print(max([x for x in divisors if x <= M // N]))

Submission status: Accepted

Solution code:
from math import sqrt

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

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

Submission status: Accepted

Solution code:
import numpy as np
 
def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort()
    return a
 
N,M = map(int,input().split())
 
f = factorization(M)
f = np.array(f)
print(np.max(f[f<=M/N]))

Submission status: Accepted

Solution code:
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行ありl
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M % i == 0:
        if M >= (M//i)*N:
            ans = M//i
            break

        ans = i



print(int(ans))

Submission status: Accepted

Solution code:
def divisore(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=divisore(m)
for i in l:
 if m//n>=i:
  print(i)
  exit()

Submission status: Accepted

Solution code:
def divisore(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=divisore(m)
for i in l:
 if m/n>=i:
  print(i)
  exit()

Submission status: Accepted

Solution code:
import math

# 入力
n, m = map(int, input().split())
# 初期値
ans = 1
# mの約数で全探索
for i in range(1, int(math.sqrt(m) + 1)):
    if m % i == 0:
        j = m // i
        if m // n >= j:
            ans = max(ans, j)
        elif m // n >= i:
            ans = max(ans, i)
print(ans)

Submission status: Accepted

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

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

ans = 1

for a in range(1, int(math.sqrt(M))+1):
  b = M // a
  if M % a != 0:
    continue

  if a * N <= M:
    ans = max(ans, a)
  
  if b * N <= M:
    ans = max(ans, b)

print(ans)

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  if n==1:
    return m

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

  return a

# main()
print(main())

Submission status: Accepted

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

n, m = map(int, input().split())
ans = 1
for i in prime_factor(m):
    if i<=m/n: ans = max(ans, i)
print(ans)

Submission status: Accepted

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

def f(x):
  l = []
  for i in range(1, int(math.sqrt(x)+1)):
    if x % i == 0:
      l.append(i)
      l.append(x//i)
  l.sort()
  return l

fac = f(M)
print(fac[bisect.bisect_right(fac, M//N)-1])

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,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
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
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)
            if i*i!=n:
                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)
    if n!=1:
        fact.append(n)
    return fact
def main():
    N,M=MI()
    D=find_divisor(M)
    ans = 1
    for d in D:
        if M//d >= N:
            ans = max(ans,d)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().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
li = make_divisors(m)
point = m
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Submission status: Accepted

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().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
li = make_divisors(m)
point = 1
if n == 1:
    print(m)
    exit()
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

#素因数分解
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a



#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])


for i in reversed(range(math.floor(M/N)+1)):
  f = M/i
  if(f.is_integer() == True):
    if(N*i<=M):
      ans = i
      break


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


divs = sorted(make_divisors(M), reverse=True)

ans = 1
for div in divs:
    res = div if div*N <= M else 1
    ans = max(ans, res)

print(ans)

Submission status: Accepted

Solution code:
from math import sqrt

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

result = 1
for i in range(1, int(sqrt(M)) + 1):
    if M % i != 0:
        continue
    t = M // i
    if t >= N:
        result = max(result, i)
    if M // t >= N:
        result = max(result, t)
print(result)

Submission status: Accepted

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

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 = [int(x) for x in input().split()]

    d = make_divisors(M)
    ma = -1
    for i in d:
        if M // i >= N:
            ma = max(ma, i)

    print(ma)


    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

d=[]
i=1
while math.sqrt(M)>=i:
    if M%i==0:
        d.append(i)
        if i**2!=M:
            d.append(M//i)
    i=i+1
d.sort()#Mの約数列

m=0
i=0
while  len(d)-1>=i and M//N>=d[i]:
    if  M%d[i]==0:
        m=d[i]
    i=i+1
print(m)

Submission status: Accepted

Solution code:
from math import sqrt

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

a = 0
flg = False
for i in range(1, int(sqrt(M)) + 1):
    if M % i==0:
        if i <= M / N:
            a = max(a, i)
        b = M // i
        if b <= M / N:
            a = max(a, b)

print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

ans = 0
divList = []
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        j = m / i
        divList.append(i)
        divList.append(j)
divList = sorted(divList)
for i in divList:
    if i < n:
        continue
    ans = m / i
    break

print(int(ans))

Submission status: Accepted

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

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=divisor(m)
d.sort(reverse=1)
for i in d:
  if m//i>=n:print(i);exit()

Submission status: Accepted

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

ans = 1

import math

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

print(max(l))

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

ans=0
table=make_divisors(M)
table.sort()

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

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())
lst = make_divisors(M)
print(lst[bisect.bisect_right(lst, M//N)-1])

Submission status: Accepted

Solution code:
def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(N**0.5) + 1):
        if N % k == 0:
            return False
    return True


N, M = map(int, input().split())
k = 0
if N != 1:
    if is_prime(M):
        print(1)
        exit()
while True:
    if M % (N + k) == 0:
        ans = M // (N+k)
        break
    k += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = M//N
ans = 0
ok = True
for i in range(1, a+1):
    if M%i == 0:
        ans = i
        if M//i <= a:
            print(M//i)
            ok = False
            break
if ok:
    print(ans)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split(" "))
    for i in range(M // N, 0, -1):
        if M % i == 0 and i <= M / N:
            print(i)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import sqrt


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

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

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def factorization(n):
    arr = Counter()
    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[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if len(arr.keys()) == 0 and n != 1:
        arr[n] = 1

    return arr


def dfs(i, x):
    global N, M, ans
    if i == len(primeKeys):
        if M // x >= N:
            ans = max(ans, x)
    else:
        for j in range(primes[primeKeys[i]] + 1):
            nx = x * (primeKeys[i] ** j)
            if M // nx >= N:
                dfs(i + 1, nx)
            else:
                break


N, M = map(int, input().split())
primes = factorization(M)
# primeList = list(primes.elements())
primeKeys = list(primes.keys())

ans = 1
dfs(0, 1)

print(ans)

Submission status: Accepted

Solution code:
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)
    return divisors

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

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)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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

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

ans = 1
for d in div:
    if M//d >= N:
        ans = max(ans,d)

print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

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

def main():
    N, M = LI()
    yakusu = get_yakusu_list(M)
    for ko in yakusu[::-1]:
        if M // ko >= N:
            break
    print(ko)

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())
for i in make_divisors(m)[::-1]:
    if n*i<=m: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)
        if M // i >= N:
            ans = max(ans, i)
print(int(ans))

Submission status: Accepted

Solution code:
import math

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

d = math.floor(M**(1/2))


factor = []
for i in range(1,d+1):
	if M % i == 0:
		factor.append(i)
		factor.append(M//i)

ans = 0
for f in factor:
	if M//f >= N:
		ans = max(ans, f)

print(ans)

Submission status: Accepted

Solution code:
import sys
from copy import copy
  
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())

factor = make_divisors(M)

for f in factor:
  if f >= N:
    print(M // f)
    sys.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


divisors = sorted(make_divisors(m), reverse=True)
for div in divisors:
    if div <= m//n:
        print(div)
        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


divisors = sorted(make_divisors(m), reverse=True)
ans = []
for div in divisors:
    if div <= m//n:
        print(div)
        exit()

Submission status: Accepted

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

print(ans)

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)
        if M // i >= N:
            ans = max(ans, i)

print(int(ans))

Submission status: Accepted

Solution code:
def make_divisors(m,n):
    divisors = []
    ans = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 and m <= n//i and ans < i:
            ans = i
            if i != n//i and m <= i and ans < n//i:
                ans = n//i
    print(ans)

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

Submission status: Accepted

Solution code:
def p_d():
    n, m = map(int, input().split())
    max_candidate = m // n
    for i in reversed(range(1, max_candidate + 1)):
        diff = m - n * i
        if diff % i == 0:
            print(i)
            break
            
p_d()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_right

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)
    ass.sort()
    return ass 

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

li = divisor(M)

x = bisect_right(li,a)

print(li[x-1])

Submission status: Accepted

Solution code:
from bisect import bisect_right

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)
    ass.sort()
    return ass 


N,M = map(int,input().split())
a = M//N
c = True

li = divisor(M)

x = bisect_right(li,a)

print(li[x-1])

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 = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_right(div,M/N)
print(div[ind-1])

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 = sorted(make_divisors(M))
div = [i for i in div if M//i >= N]
print(div[-1])

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
arr = make_divisors(M)
from bisect import bisect_left, bisect_right
l = bisect_left(arr, N)
print(M//arr[l])

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


def solve():
    N, M = map(int, input().split())
    
    divs = make_divisors(M)
    ans = 0
    for div in divs:
        if div <= M / N:
            ans = max(ans, div)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

# Mの約数を求める
yaku = [ M, 1 ]
i = 2
mm = M
while (i * i) <= M:
    if mm % i == 0:
        yaku.append(i)
        yaku.append(mm//i)
    i += 1
#print(yaku)

# Mの約数の大きい順に判定していく
yaku.sort( reverse=True )

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

Submission status: Accepted

Solution code:
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = set()
for i in range(1, sqrtm):
    if M % i == 0:
        D.add(i)
        D.add(M // i)
D = sorted(list(D))
ans = 0
for d in D:
    if d * N <= M:
        ans = d
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)

    return divisors


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

ans = 0
for i in make_divisors(m):
    if i <= m / n:
        ans = max(ans, i)

print(ans)

Submission status: Accepted

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

# Mの約数列挙
divs = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divs.append(i)
        divs.append(M // i)

ans = 0
divs.sort(reverse=True)
for d in divs:
    if N * d <= M:
        print(d)
        exit()

Submission status: Accepted

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

# Mの約数列挙
divs = set()
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divs.add(i)
        divs.add(M // i)

ans = 0
for d in divs:
    if N * d <= M:
        ans = max(ans, d)

print(ans)

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)
            ass.append(n//i)
    return ass


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

K = divisor(M)

ans = 0
for k in K:
    if N * k <= M:
        ans = max(ans, k)


print(ans)

Submission status: Accepted

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

A=M//N
for i in range(A,0,-1):
    Z=M%i
    if not Z or Z%i==0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# AGC112 D - Partition
from math import floor
def divisor(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


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

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max:
        print(i)
        exit()

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 j in D:
  if j >=N:
    print(M//j)
    exit()

Submission status: Accepted

Solution code:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
ans = 0
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

Submission status: Accepted

Solution code:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def divisor(n: int) -> list:
    list_of_divisor = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            list_of_divisor.append(i)
            if i != n//i:
                list_of_divisor.append(n//i)
    list_of_divisor.sort()
    return list_of_divisor

div = divisor(M)
for i in div[::-1]:
    if i <= M/N:
        print(i)
        exit()

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 i * N <= M:
            ans = max(ans, i)
        if (M // i) * N <= M:
            ans = max(ans, M // i)
print(ans)

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()
    return divisors
a=divisor(M)
ans=1
for i in a:
    if i *N<=M:
        ans=i
print(ans)

Submission status: Accepted

Solution code:
N,M=[int(x) for x in str(input()).split()]
count=0
ans=[]
for i in range(1,int(M**0.5+2)):
  #print(i)
  if M%i==0 and i>=N:
    count=1
    ans.append(M//i)
    break

for i in range(1,int(M**0.5+2)):
  #print(i)
  if M%i==0 and M//i>=N:
    ans.append(i)
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import math
gs = []
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0:
    gs.append(i)
    if i != m//i:
      gs.append(m//i)

gs.sort(reverse=True)

#print(gs)
for j in gs:
  if m//j >= n:
    print(j)
    exit()