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: Wrong Answer

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

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

Submission status: Wrong Answer

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

n, m = nm()
ans = 1
for i in range(2, n + 1):
    if m % i == 0 and m // i >= n:
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    exit()
c = 1
for i in range(2, math.ceil(pow(M, 0.5))+1):
    if M % i == 0:
        if i < N:
            c = i
        else:
            print(M // i)
            exit()
print(c)

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    exit()
c = 1
for i in range(2, math.ceil(pow(M, 0.5))):
    if M % i == 0:
        if i < N:
            c = i
        else:
            print(M // i)
            exit()
print(c)

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    exit()
c = 1
for i in range(2, math.floor(pow(M, 0.5))):
    if M % i == 0:
        if i < N:
            c = i
        else:
            print(M // i)
            exit()
print(c)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if int(math.sqrt(M)) > N:
    for i in range(M//N,0,-1):
        if M%i == 0:
            ans = i
            break
        else:
            continue
else:
    for i in range(N,0,-1):
        if M%i == 0:
            ans = i
            break
        else:
            continue

print(ans)

Submission status: Wrong Answer

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

if int(math.sqrt(M)) > N:
    for i in range(N,0,-1):
        if M%i == 0:
            ans = i
            break
        else:
            continue
else:
    for i in range(int(M/N),0,-1):
        if M%i == 0:
            ans = i
            break
        else:
            continue

print(ans)

Submission status: Wrong Answer

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

for d in range(N, M):
  if M % d == 0:
    print(M // d)
    break

Submission status: Wrong Answer

Solution code:

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

    if N == 1:
        print(M)
    else:
        now_ans = 1
        for i in range(2, int(M ** 0.5) + 1):
            if M % i == 0:
                a = i
                b = M // i
                if a >= N:
                    now_ans = b
                    break
                elif b <= N:
                    now_ans = a
                    break
                now_ans = i
        print(now_ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,raw_input().split())
F=[]
i=1
while i * i <= M:
    if M%i==0:
        F.append(i)
        if i!=1 and i*i!=M: F.append(M/i)
    i+=1
F.sort()    
ans=-1
for k in F:
    if (M/k-N>=0):
        ans=k
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

ans = 1
for i in range(2,10000+1):
	k = M % i
	if k == 0:
		if M//i >= N:
			ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**6), -1):
        if M % i == 0:
            print(i)
            break
    else:
        tmp = 1
        for i in range(2, min(upper, 10**6)):
            if M % i == 0:
                tmp = i
        print(tmp)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**5), -1):
        if M % i == 0:
            print(i)
            break
    else:
        tmp = 1
        for i in range(2, min(upper, 10**5)):
            if M % i == 0:
                tmp = i
        print(tmp)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**5), -1):
        if M % i == 0:
            print(i)
            break
    else:
        tmp = 1
        for i in range(2, min(upper, 10**5)):
            if M % i == 0:
                tmp = i
        print(i)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**5), -1):
        if M % i == 0:
            print(i)
            break
    else:
        for i in range(2, min(upper, 10**5)):
            tmp = 1
            if M % i == 0:
                tmp = i
        print(i)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**5), -1):
        if M % i == 0:
            print(i)
            break
    else:
        for i in range(2, 10**5):
            tmp = 1
            if M % i == 0:
                tmp = i
        print(i)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    for i in range(upper, max(0, upper-10**5), -1):
        if M % i == 0:
            print(i)
            break
    else:
        print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

	total = m//n
	current_max = 1
	for i in range(1, total+1):
		if i * i > m:
			break
		if m % i == 0:
			div = m // i
			current = max(i, div) if div < total and div <= n else i
			if current > current_max:
				current_max = current

	print(current_max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

	total = m//n
	current_max = 1
	for i in range(1, total+1):
		if i * i > m:
			break
		if m % i == 0:
			div = m // i
			current = max(i, div) if div < total else i
			if current > current_max:
				current_max = current

	print(current_max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

	total = m//n
	current_max = 1
	for i in range(1, total+2):
		if m % i == 0:
			current_max = i
		if i * i > m:
			break

	print(current_max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

	print(current_max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(n)

Submission status: Wrong Answer

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

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

print(n)

Submission status: Wrong Answer

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

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

print(n)

Submission status: Wrong Answer

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

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

print(n)

Submission status: Wrong Answer

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

n = 0
for i in range(1, M):
    if M % i == 0:
        n = i
    if M < i * N:
        break

print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


ans=0

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
ans = 0
for i in range(1, int(math.sqrt(m))) :
  if(m%i == 0 and m/n >= i) :
    ans  = i
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
if m%n==0:
  print(int(m/n))
else:
  print(gcd(m%n,m))

Submission status: Wrong Answer

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

ans = 1
for i in range(2,10000+1):
	k = M % i
	if k == 0:
		if M//i >= N:
			ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []

for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0:
        l.append(i)
l.reverse()
for i in l:
    if i <= math.floor(M/N):
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []

for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0:
        l.append(i)
l.reverse()
for i in l:
    if i <= math.ceil(M/N):
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0:
        l.append(i)
for i in l[::-1]:
    if i <= N:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0:
        l.append(i)
for i in l[::-1]:
    if i <= math.floor(M/N):
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []
for i in range(1,math.ceil(math.sqrt(M))+1):
    if M%i == 0:
        l.append(i)
for i in l[::-1]:
    if i <= math.ceil(M/N):
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
l = []
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0:
        l.append(i)
for i in l[::-1]:
    if i <= M/N:
        print(i)
        exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 1
for i in range(1, int(m**(0.5))):
    if m%i==0:
        d = m//i
        if d >= n:
            ans = i if i<n else d
        else:
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for i in range(1, int(math.sqrt(m))):
  if m%i == 0 and i < int(m/n):
    ans = i
    
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
prime = []
if m%n == 0:
    print(m//n)
else:
    nl = 1
    nm = 1
    nlsub = 1
    flag = 1
    while flag == 1:
        for i in range(2,m+1):
            if m%i == 0:
                m //= i
                if nlsub < n:
                    nlsub *= i
                if i > n:
                    nl *= i
                else:
                    nm *= i
                break
        if m == 1:
            flag = 0
    if nl > n:
        print(nm)
    else:
        print(m//nlsub)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
prime = []
if m%n == 0:
    print(m//n)
else:
    nl = 1
    nm = 1
    flag = 1
    while flag == 1:
        for i in range(2,m+1):
            if m%i == 0:
                m //= i
                if i > n:
                    nl *= i
                else:
                    nm *= i
                break
        if m == 1:
            flag = 0
    print(nm)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
for i in reversed(range(1,min(M//N,int(M**0.5))+1)):
    if M%i == 0:#約数（m）の大きい順にM→M/mとしたときにNこの最大公約数が1になるか（というかM/mをN個にわけることができるか、で十分）を調べる
        if M/i>=N:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
for i in reversed(range(1,min(M//N,int(M**0.5))+1)):
    if M%i == 0:#約数（m）の大きい順にM→M/mとしたときにNこの最大公約数が1になるか（というかM/mをN個にわけることができるか、で十分）を調べる
        if M/i>=N:
            print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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


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


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

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

    print(int(ans))
    return


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
mm = math.floor(math.sqrt(M)) + 1
# a * b = M (a < b) であってaが最小、bが最大のもの
a = 1
for i in range(mm, 0, -1):
  if M % i == 0:
    a = i
    break
b = M // a
#print(a, b)
if a >= N:
  print(b)
else:
  print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
for i in range(1,1000001):
    if m%i==0 and m/n>=i:
        d = i
    i+=1
print(d)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
for i in range(1,100001):
    if m%i==0 and m/n>=i:
        d = i
    i+=1
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
i = 1
while i*i<=m+1:
    if m%i==0 and m/n>=i:
        d = i
    i+=1
print(d)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
i = 1
while i*i<=m:
    if m%i==0 and m/n>=i:
        d = i
    i+=1
print(d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    print(ans)

Submission status: Wrong Answer

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