Problem:


Score : 400 points

Problem Statement

You are given integers N and M.

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

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

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

Sample Input 1

3 14

Sample Output 1

2

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

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000



Sample input:
3 14


Sample output:
2

Submission status: Accepted

Solution code:
import math

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

p = []

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

ret = 1
for i in p:
    if m // i >= n:
        ret = max(ret,i)
#print(p)
print(ret)

Submission status: Accepted

Solution code:
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:
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  gcd = m//n
  n = 1 + (m-1)//gcd
print(gcd)

Submission status: Accepted

Solution code:
import sys
n,m=map(int,input().split())
a=m//n
ans=1
if m%n==0:
  print(int(m//n))
  sys.exit()
for i in range(1,a+1):
    if m%i==0:
        ans=max(ans,i)
print(ans)

Submission status: Accepted

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

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

div.sort(reverse=True)
for i in div:
    if m >= i * n and (m - i * n) % i == 0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import math
N, M = map(int,input().split())
P = [1]
for k in range(2,math.floor(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
P = sorted(P)
if N == 1:
    print(M)
    exit(0)

ans = 1
for p in P:
    if p*N <= M:
        ans = p

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

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

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

n,m = li()

divs = divisors(m)

ans = 1
for di in divs:
    if n*di <= m:
        ans = max(ans, di)

print(ans)

Submission status: Accepted

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


def main():
    from math import sqrt

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

    for k in range(1, int(sqrt(m)) + 1):
        p, q = divmod(m, k)

        if q == 0 and p * n <= m:
            ans = max(ans, p)

        if q == 0 and m // p * n <= m:
            ans = max(ans, m // p)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
divs = set()
n = 1
while n*n <= M:
    if M%n == 0:
        divs.add(n)
        divs.add(M//n)
    n += 1

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

Submission status: Accepted

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

divs = set()
n = 1
while n*n <= M:
    if M%n == 0:
        divs.add(n)
        divs.add(M//n)
    n += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


mod = M % N
div = M // N
if mod == 0:
    print(M//N)
    exit()

f = primes(M)

# 素数の場合などは１
if len(f) == 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

# print(cnt)
# print(list(itertools.product(*tmp_list)))
for p in itertools.product(*tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        tmp = tmp * (k ** i)

    if tmp > N:
        ans_list.append(M//tmp)

if len(ans_list) == 0:
    print(1)
else:
    print(max(ans_list))

Submission status: Accepted

Solution code:
import math
N, M = list(map(int, input().split()))
if N == 1:
  print(M)
  exit()
X = int(math.sqrt(M))+1
for i in range(N, X):
  if M % i == 0:
      print(int(M/i))
      exit()
X = int(M / N)
for i in range(X, 0, -1):
  if M % i == 0:
      print(i)
      exit()
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder
'''
if Q>R :
    k=int((Q-R)//(1+N))
    k-=1
    Q -= k
    R += k*N
    '''
memo=0
while R%Q != 0:
    k= int((Q-R%Q)//(N+R//Q+1))   #max k:k*(N+R//Q)<Q-k
    #print(R,Q,R%Q,R//Q,k)
    while (R+k*N)//(Q-k) > memo:
        k -= 1
        #print(k,memo,(R+k*N)//(Q-k))
    if k > 0:
        Q -= k
        R += k*N
        memo=R//Q
    else:
        Q -= 1
        R += N
        memo=R//Q

print(Q)

Submission status: Accepted

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

def divisor(m):
    ans = []
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
j = len(divs) - 1
while True:
    if divs[j] * n <= m:
        print(divs[j])
        break
    j -= 1

Submission status: Accepted

Solution code:
from math import *

N, M = map(int, input().split())
special_value = M//N
divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
divisor_set = divisor_set.union(M//j for j in divisor_set)
print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

main()

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max([i for i in divisor_set if special_value >= i])))
    return

main()

Submission status: Accepted

Solution code:
from math import *
N, M = map(int, input().split())
special_value = M//N
divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
divisor_set = divisor_set.union(M//j for j in divisor_set)
print(int(max([i for i in divisor_set if special_value >= i])))

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

main()

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(set(M//j for j in divisor_set))
    print(int(max([i for i in divisor_set if special_value >= i])))

    return

main()

Submission status: Accepted

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M/j for j in divisor_set)
    print(int(max([i for i in divisor_set if special_value >= i])))
    return

main()

Submission status: Accepted

Solution code:
import math


def prime(M):
    if M == 1:
        return [1]
    lst = []
    for i in range(1, int(math.sqrt(M)+1)):
        if M % i == 0:
            lst.append(i)
            div = M // i
            if div not in lst:
                lst.append(div)
    return sorted(lst)


N, M = map(int, input().split())
lst = prime(M)
res = 1
for num in lst:
    if (M // N) < num:
        break
    else:
        res = num

print(res)

Submission status: Accepted

Solution code:
import math

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

if N == 1:
    print(M)
else:
    divisor = []
    n = int(math.sqrt(M))
    for i in range(1, n+1):
        if M % i == 0:
            tmp = M // i
            if not i in divisor:
                divisor.append(i)
            if not tmp in divisor:
                divisor.append(tmp)
    maximize = 0
    threshold = M // N
    for item in divisor:
        if item <= threshold and maximize < item:
            maximize = item

    print(maximize)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt

n,m=map(int,input().split())
#print(n,m)
l=[]
for i in range(1,int(sqrt(m))+1):
    if m%i == 0:
        l.append(i)
        l.append(m//i)
l.sort(reverse=True)
for i in l:
    if i*n<=m:
        print(i)
        break

Submission status: Accepted

Solution code:
def soinsuubunkai(n):
    i = 2
    list = [1]
    while i**2 <= n:
        if n%i == 0:
            list.append(i)
            if i != n//i:
                list.append(n//i)
        i += 1
    list.append(n)
    return list
n, m = map(int, input().split())
l = soinsuubunkai(m)
l.sort()
r = len(l)
for i in range(r):
    if m//l[r-i-1] >= n:
        print(l[r-i-1])
        quit()

Submission status: Accepted

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


gcd=1
while(1):
    if(M%i==0):
        print(M//i)
        sys.exit(0)
    if(i**2 >M):
        break
    i+=1

i=M//N
while(1):
    if(M%i==0):
        print(i)
        sys.exit(0)
    i-=1

Submission status: Accepted

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break

Submission status: Accepted

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().strip().split())
st= min(M//N,int(math.sqrt(M)))
cand=0
if M//N <= int(math.sqrt(M)):
    for i in range(M//N,0,-1):
        if M%i==0:
            print(i)
            break
else:
    for i in range(1,int(math.sqrt(M)),1):
        if M%i==0:
            if M//N >= i:
                cand=max(cand,i)
            if M//N >= M//i:
                cand=max(cand,M//i)
    print(cand)

Submission status: Accepted

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

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

Submission status: Accepted

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

c = [1]
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0 :
        if i <= M//N and M//i > M//N:
            c.append(i)
        if i <= M//N and M//i <= M//N:
            c.append(M//i)
        else:
            continue
c = sorted(c)
print(c[-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''input
100000 1000000000
'''
from math import sqrt
def div(n):
	s = set()
	for i in range(1,int(sqrt(n))+1):
		if n%i == 0:
			s.add(i)
			s.add(n//i)
	return s
n,m = map(int,raw_input().split())
s = div(m)
aa = -1
for i in s:
	if i*n <= m:
		aa = max(aa,i)
print aa

Submission status: Accepted

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

# x:gcd
# M//x >= N:解はこの値より小さいか、
# x >= N:この値より大きくなるはず
ans = 1
x = 1
while x * x <= M:
    if M % x == 0:
        if x >= N:
            ans = max(ans, M//x)
        if M//x >= N:
            ans = max(ans, x)
    x += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

yueshu = []
state = 0
if m % n == 0:
    print m / n
else:
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            yueshu.insert(0, m/i)
            if i >= n:
                print m / i
                state = 1
                break
    if state == 0:
        for i in yueshu:
            if m % i == 0:
                if i >= n:
                    print m / i
                    state = 1
                    break
    if state == 0:
        print 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
d = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0:
        d.append(i)
        d.append(int(M / i))
d = list(filter(lambda x: x <= int(M / N), d))
print(max(d))

Submission status: Accepted

Solution code:
def calc():
 N,M = map(int,input().split())
 for gcd in range(M // N,0,-1):
  if M % gcd == 0:
   break
 return(gcd)
print(calc())

Submission status: Accepted

Solution code:
n, m = 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:
#coding: utf-8
import math

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

a = []
root_m = int(math.sqrt(m)) + 1
for i in range(1,root_m):
    if m%i == 0:
        a.append(m/i)
        if i >= n:
            print m/i
            exit()
for i in reversed(a):
    if m%i == 0:
        if i >= n:
            print m/i
            exit()
print "1"

Submission status: Accepted

Solution code:
import sys


def divisor_gen(n):
    ret = set()
    for i in range(1, int(n ** (1 / 2) + 1)):
        if n % i == 0:
            ret.add(i)
            ret.add(int(n/i))
    return sorted(list(ret), reverse=True)


# print(divisor_gen(1000))


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

for d in divisor_gen(M):
    if N <= (M / d):
        print(d)
        sys.exit(0)

Submission status: Accepted

Solution code:
import sys


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

    ans = 1

    for i in range(1, m + 1):
        if i*i > m:
            break
        if m % i == 0 and i * n <= m:
            ans = max(ans, i)

            if (m // i) * n <= m:
                ans = m // i
                break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
import math

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

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

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

divisors.sort()
MAX_VAL = int(M/N)
for d in divisors:
    if d > MAX_VAL:
        break
    max_gcd = d

print(max_gcd)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = list(filter(lambda x: x <= M//N, divisors))

print(divisors[0])

Submission status: Accepted

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

def factorize(x):
    fac = []
    for i in range(1, int(x**0.5)+1):
        if (x % i) == 0:
            fac.append(i)
            fac.append(M//i)
    return sorted(fac)

fac = factorize(M)
fac = filter(lambda x: x <= int(M/N), fac)

print(max(fac))

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = filter(lambda x: x <= M//N, divisors)
 
for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Submission status: Accepted

Solution code:
import math

#mの約数のうち、n以上の最小の約数でmを割った商が答え
inn,inm = list(map(int,input().split()))
root = math.floor(math.sqrt(inm))

a = []
for i in range(1,root+1):
  if inm%i == 0:
    a.append(i)
    a.append(inm/i)
    
a.sort()
for i in a:
  if i >= inn:
    print(int(inm/i))
    break

Submission status: Accepted

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

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

ans = 0
for d in divisor:
    if M // d >= N:
        ans = max(ans, d)

print(ans)

Submission status: Accepted

Solution code:
import sys
from math import sqrt

n, m = map(int, input().split())
isqrtm = int(sqrt(m))
for revdiv in range(1, 1+isqrtm):
	if m % revdiv == 0:
		div = m // revdiv
		if div <= m//n:
			print(div)
			sys.exit()
for div in range(isqrtm, 0, -1):
	if m % div == 0:
		if div <= m//n:
			print(div)
			sys.exit()

Submission status: Accepted

Solution code:
import sys

n, m = map(int, input().split())
for div in reversed(range(1, 1+m//n)):
	if m % div == 0:
		print(div)
		sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# nの約数を求める
def divisor(n):
    d = []
    for i in range(int(n**(0.5)+1))[1:]:
        if n % i == 0:
            d.append(i)
            if i * i != n:
                d.append(int(n / i))
    return d


N, M = map(int, input().split())
# d はnの約数のベクター
d = divisor(M)
g = int(M / N)
d = [x for x in d if x <= g]
print(max(d))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
i = 1
ans = 0
while i*i<=M:
    if M%i != 0:
        pass
    else:
        j = M//i
        if i*N <= M:
            ans = max(ans, i)
        if j*N <= M:
            ans = max(ans, j)
    i += 1
print(ans)

Submission status: Accepted

Solution code:
import math


def main():
    ret = 0
    n, m = map(int, input().split())
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0 and n * i <= m:
            ret = max([ret, i])
        if m % i == 0:
            j = m //i
            if n * j <= m:
                ret = max([ret, j])
    print(ret)
main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def solve():
    N, M = map(int, input().split())
    for i in range(M//N,0,-1):
        if not M%i: 
            return str(i)

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
import math
import bisect


def divisorGenerator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor
        
a = input().split()
a = [int(i) for i in a]
lister = list(divisorGenerator(a[1]))
ind = bisect.bisect_left(lister, a[0])
print(a[1] // lister[ind])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())
if n==1:
    print(m)
    exit()
mm = int(math.sqrt(m))
a = []
for i in range(1,mm):
    if m%i == 0:
        a.append(i)
        a.append(m//i)
ans = 1
for D in a:
    if m - (n-1)*D >= D:
        ans = max(ans,D)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max = m//n
lis = []


for i in range(int(m**0.5)):
    if i != 0 and m%i == 0:
        lis.append(i)
l = len(lis)
for i in range(l):
    if m/lis[i] != lis[i]:
        lis.append(m//lis[i])

lis.sort()
lis = lis[::-1]

if m%n == 0:
    print(max)
else:
    for line in lis:
        if line > max:
            continue
        else:
            if m/line > n:
                print(line)
                break

Submission status: Accepted

Solution code:
import sys
n,m=map(int,input().split())
if n==1:
    print(m)
    sys.exit()
ans=[]
i=int(1)
while i<=m/i:
    if m%i!=0:
        i+=1
    elif m%i==0:
        j=int(m/i)
        if j>=n:
            ans.append(i)
        if i>=n:
            ans.append(j)
        i+=1
ans.sort()
print(ans[len(ans)-1])

Submission status: Accepted

Solution code:
import math
N,M= map(int, input().split())
 
answer = 1
list = []
for i in range(1,math.floor(M**(1/2))+1):
    if M % i == 0 and int(M/i) >= N:
        answer = i
        list.append(int(M/i))
 
 
for k in list:
    if M/k >= N:
        answer = k
        break
 
print(answer)

Submission status: Accepted

Solution code:
# coding:utf-8


def inpl(): return list(map(int, input().split()))


N, M = inpl()

A = 1
ans = 1
while A * A <= M:
    # 約数判定
    if M % A != 0:
        A += 1
        continue
    B = M // A

    # dはM // N以下
    if A * N <= M:
        ans = max(ans, A)
    # M = A * BでAはsqrt(M)までしか探索しない
    # 答えがsqrt(M)以上M // N以下のときWAになるので
    # AだけではなくBでも判定を行う
    # だから全探索の時は必要なかったのか...
    if B * N <= M:
        ans = max(ans, B)

    A += 1

print(ans)

Submission status: Accepted

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

divs = []
for i in range(1, int(m ** (1 / 2)) + 1):
  if m % i == 0:
    divs.append(i)
    divs.append(m // i)

divs.sort(reverse=True)
x = m // n

for i in divs:
  if i <= x:
    print(i)
    break

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x=1
s=1
while x**2<=m:
  a,b=divmod(m,x)
  if a>=n and b==0:
    s=max(x,s)
  if x>=n and b==0:
    s=max(a,s)
  x+=1

print(s)

Submission status: Accepted

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

ans = 1
sosu = True if M % 2 == 1 else False

if M % 2 == 1:
    sqrt = int(math.ceil(math.sqrt(M)))
    for i in range(3, sqrt, 2):
        if M % i == 0:
            sosu = False
            break

if sosu == False:
    for i in range(N, M):
        if M % i == 0:
            ans = M / i
            break


print(int(ans))

Submission status: Accepted

Solution code:
import numpy as np
N, M = list(map(int, input().split()))
can = []
for i in range(1, int(np.sqrt(M)) + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		if N <= i:
			can.append(M // i)

if N == 1:
	print(M)
else:
	print(max(can))

Submission status: Accepted

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

def yakusuu(n,m):
    for i in range(int(m/n),0,-1):
        if m % i == 0:
            print(i)
            break

yakusuu(n,m)

Submission status: Accepted

Solution code:
import math;a = list(map(int,input().split()));b = a[1]//a[0];c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True);print(c[0])

Submission status: Accepted

Solution code:
import math
a = list(map(int,input().split()))
b = a[1]//a[0]
c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True)
print(c[0])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

N, M = sys.stdin.readline().strip().split()
N = int(N)
M = int(M)
P = M//N # これ以下で最大の、Mの約数を探す
Q = math.floor(math.sqrt(M)) #sqrt。解の探索範囲を絞るのに使う

# Mでないなら高々sqrt(M)


if P <= Q:
  # P=M/Nから1つずつ下がって探索
  for x in range(P, 0, -1):
    # print(x)
    if M % x == 0:
      print(x)
      break
elif P == M: # N=1
  print(M)
else:
  #1からQ=sqrt(M)まで増やす
  res = 1
  flag = 0
  for x in range(1, N, 1):
    # このときM/xはPより大きいことに注意
    if M % x == 0:
      res = x
  for x in range(N, Q+1, 1):
    if M % x == 0:
      print(M//x)
      flag = 1
      break
  if flag == 0:
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

solve()