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:
# coding : utf-8

import math

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

b = M//N

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

ans = 1
for l_ in l:
    if l_ <= b:
        ans = max(ans,l_)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)



for i in s:
	if m%(i)==0 and m//(i)>n-1:
		x=max(x,i)
print(x)

Submission status: Wrong Answer

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

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d+1,0,-1):
    	if M%d == 0:
    		print(d)
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)



for i in s:
	if m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Wrong Answer

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

import math

div = []

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

#print(div)

div.sort()

now = 0

for i in div:
    if n > m / i:
        break

    now = i


print(now)

Submission status: Wrong Answer

Solution code:
import math

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

x=math.floor(math.sqrt(m))
y=math.floor(m/n)

s=min(x,y)

ans=1
for i in range(1,s+1):
  if(m % i==0):
    ans=i
    
print(ans)

Submission status: Wrong Answer

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

a = []
x = 1
while x * x < M:
    if M % x == 0:
        a.append(x)
    x += 1

res = 0
for i in a:
    if M / i >= N:
        res = max(res, i)
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)



for i in s:
	if m%(i+1)==0 and m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Wrong Answer

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

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

for i in range(len(yakusuu) - 1, 0, -1):
    if M / yakusuu[i] >= N:
        print(yakusuu[i])
        break

Submission status: Wrong Answer

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)

Submission status: Wrong Answer

Solution code:
# coding : utf-8

import math

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

b = M//N

print(min(max([i for i in range(1,int(math.sqrt(M))+1) if M%i == 0]),b))

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if M > 1 or len(prime_dic) == 0:
    prime_dic[M] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    #if M//mul < N:
    #    return

    if p >= len(prime_dic):
        if M//mul >= N and mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

Submission status: Wrong Answer

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

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

for i in range(len(yakusuu) - 1, 0, -1):
    if M / yakusuu[i] >= N:
        print(yakusuu[i])
        break

Submission status: Wrong Answer

Solution code:
import math

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

x=math.floor(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if(m % i==0):
    ans=i
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,T  = map(int,input().split())
 
if T % N == 0:
    print (int(T / N))
    exit()
    
for i in range(T):    
    A = math.ceil(T / N)
    print(A)
    if T % A ==0:
        print(T)
        break
    T = A

Submission status: Wrong Answer

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

a = []
x = 1
while x * x <= M:
    if M % x == 0:
        a.append(x)
    x += 1

res = 0
for i in sorted(a, reverse=True):
    k = M / i
    if k >= N:
        res = max(res, i)
print(res)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = TMPM//i

if M > 1:
    prime_dic[M] = 1


max_mul = 1
def Rec(mul, p):
    global max_mul
    #if M//mul < N:
    #    return

    if p >= len(prime_dic):
        if M//mul >= N and mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

Submission status: Wrong Answer

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

ans = 1

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

for i in range(2,ceil(sqrt(M))+1):

    temp = M

    temp -= i * (N-1)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Submission status: Wrong Answer

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if m > m / i:
        break
    maxans = i
print(maxans)

Submission status: Wrong Answer

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

def make_divisor_list(num,tar):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i_max = int(math.sqrt(M))

        for i in range(2, i_max):
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(num//i)

        return divisor_list
def binary_search_loop(li,tar):
    arry = li
    target = tar
    result = None
    left = 0
    right = len(arry) - 1

    while left <= right:
        mid = (left + right) // 2
        # if arry[mid] == target:
        #     result = mid
        #     break
        if arry[mid] > target:
            right = mid - 1
        else:
            left = mid + 1
#    print(mid)
    return mid

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

li = make_divisor_list(M,M//N)
mid = binary_search_loop(li,M//N)
ans = M//li[mid]
print(ans)
# print(li)

# ans = 1
# for l in li[::-1]:
#     if l >= N:
#         ans = max(ans,M//l)
#     if ans >= l:
#         break

# i = 1
# ans = 0
# tmp = 1000000000

# if M%N == 0:
#     ans = max(ans,M//N)
#     print(ans)
#     exit()

# while M//i >= i and N > i and i <= tmp:
#     if M%i == 0:
#         if tmp == 1000000000:
#             tmp = M//i
#         if M//i >= N:
#             ans = max(ans,i)
#     i += 1

#print(ans)

Submission status: Wrong Answer

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

a = []
x = 1
while x * x <= M:
    if M % x == 0:
        a.append(x)
    x += 1

for i in sorted(a, reverse=True):
    k = M / i
    if k >= N:
        print(i)
        exit(0)

Submission status: Wrong Answer

Solution code:

iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , min(iM // iN + 1,int(iM ** 0.5)+1) + 1):
        if iM % i == 0:
            aRet.append( i )
    print( aRet[-1] )

Submission status: Wrong Answer

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if mdn < i:
        break
    maxans = i
print(maxans)

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = TMPM//i

if M > 1:
    prime_dic[M] = 1


max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

Submission status: Wrong Answer

Solution code:
def make_divisor_list(num):
    if num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i=2
        while i*i <= num:
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(int(num/i))
            i+=1
        divisor_list.append(num)
        return divisor_list
      
ans=1
N,M=map(int,input().split())
divisors=make_divisor_list(M)
divisors.reverse()
for i in range(len(divisors)):
  if divisors[i] <= int(M/N) :
    print(divisors[i])
    break

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int, input().split())
if m%n==0:
    print(m//n)
else:
    def make_divisor_list(num):
        if num < 1:
            return []
        elif num == 1:
            return [1]
        else:
            divisor_list = []
            divisor_list.append(1)
            for i in range(2, int(math.sqrt(num)) + 1):
                if num % i == 0:
                    divisor_list.append(i)
            divisor_list.append(num)

            return divisor_list
    
    listD = make_divisor_list(m)
    index =0
    while index <len(listD):
        if listD[index]>n-1:
            print(m//listD[index])
            break
        index+=1

Submission status: Wrong Answer

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m))
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if mdn < i:
        break
    maxans = i
print(maxans)

Submission status: Wrong Answer

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

ds = [x for x in range(1, int(m**.5)+1) if m%x==0]
ds = ds + [m%x for x in ds]
ds = [x for x in ds if x<=m//n]
print(max(ds))

Submission status: Wrong Answer

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

ans = 1
 

for i in range(2,int(M**.5)+1):

    if M % i != 0:
        continue
    
    if N * i <= M:
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    list = []
    for i in range(1,int(math.sqrt(M)+1)):
        if M%i == 0:
            list.append(i)
    for i in range(len(list)):
        list.append(int(M/list[i]))
    list.reverse()
    for i in range(len(list)):
        if M/list[i] >= N:
            print(list[i])
            exit()

Submission status: Wrong Answer

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = TMPM//i

if M > 1:
    prime_dic[M] = 1


max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        if i == 0:
            Rec(mul, p+1)
        else:
            Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

Submission status: Wrong Answer

Solution code:
def make_divisor_list(num):
    if num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i=2
        while i*i <= num:
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(int(num/i))
            i+=1
        divisor_list.append(num)
        return divisor_list
      
ans=1
N,M=map(int,input().split())
divisors=make_divisor_list(M)
divisors.reverse()
for i in range(len(divisors)):
  if M/divisors[i] >= N :
    print(divisors[i])
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

divisors = []
for i in range(1, ceil(sqrt(M)) + 1):
    if M % i == 0:
        divisors.append(i)
max_possible_divisor = 1
threshold = M // N
for divisor in divisors:
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Submission status: Wrong Answer

Solution code:
from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

divisors = []
for i in range(1, ceil(sqrt(M)) + 1):
    if M % i == 0:
        divisors.append(i)
max_possible_divisor = 0
threshold = M // N
for divisor in divisors:
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Submission status: Wrong Answer

Solution code:
iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range( 1 , min(iM // iN + 1,int(iM ** 0.5)) ):
        if iM % i == 0:
            aRet.append( i )
    print( aRet[-1] )

Submission status: Wrong Answer

Solution code:
N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
	for i in range(d):
		if M%(d-i) == 0:
			print(d-i)
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

Submission status: Wrong Answer

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m))
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)

mdn = m // n
for i in params:
    if mdn <= i:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def make_divisor_list(num):
    if num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i=2
        while i*i <=num:
            if num % i == 0:
                divisor_list.append(i)
            i+=1
        divisor_list.append(num)
        return divisor_list
      
ans=1
N,M=map(int,input().split())
divisors=make_divisor_list(M)
divisors.reverse()
for i in range(len(divisors)):
  if M/divisors[i] >= N :
    print(divisors[i])
    break

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.5)+1):
        if m % i == 0 and m >= n * i:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

for i in range(len(yakusuu) - 1, 0, -1):
    if M / yakusuu[i] >= N:
        print(yakusuu[i])
        break

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    for p in reversed(range(int(math.sqrt(M)) + 1)):
        if M % p == 0 and p <= M // N:
            print(p)
            break

Submission status: Wrong Answer

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

ans = 1
 

for i in range(2,int(M**.5)+1):

    temp = M

    temp -= i * (N-1)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor, sqrt
N, M = [int(elem) for elem in input().split(' ')]

divisors = []
for i in range(floor(sqrt(M)), 1, -1):
    if M % i == 0:
        divisors.append(i)

max_possible_divisor = 0
threshold = M // N
for divisor in divisors:
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

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

result = []


def factorization(a):
    if a == 1:
        return
    for i in range(2, a + 1):
        if a % i == 0:
            result.append(i)
            factorization(int(a / i))
            return

#Mの素因数分解
factorization(M)
M_factors = result

#M_factorsの中で、N*αがM以下である最大となる因数αを算出
M_factors = [x for x in M_factors if N * x < M]

answer = 0

import operator
from functools import reduce


def search(M_factors, accept=[], reject=[]):
    global answer
    seki = reduce(operator.mul, accept, 1)

    if N * seki > M:
        return
    if seki >= answer:
        answer = seki
    if len(M_factors) == 0:
        return

    candidate = M_factors[0]
    search(M_factors[1:], accept + [candidate], reject)
    search(M_factors[1:], accept, reject + [candidate])


search(M_factors)
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import time

start=time.time()
n,m = map(int, input().split())
 
amari=m % n
x=int((m-amari)/n)
 
ans=1
for i in range(1,x+1):
  if(time.time()-start<1.8):
    if(m % i==0):
      ans=i
  else:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1, ceil(sqrt(n))+2):
        if not n % i:
            l.append(i)
    return l

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

if N == 1:
    print(M)
else:    
    f = factorization(M)
    print(max([i for i in f if i <= M/N]))

Submission status: Wrong Answer

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

ans = 1
 

for i in range(2,ceil(sqrt(M))+1):

    temp = M

    temp -= i * (N-1)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1, ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
    return l

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

if N == 1:
    print(M)
else:    
    f = factorization(M)
    print(max([i for i in f if i <= M/N]))

Submission status: Wrong Answer

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

ans = 1
 

for i in range(2,floor(sqrt(M))):

    temp = M

    temp -= i * (N-1)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1, ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
    return l

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

f = factorization(M)

print(max([i for i in f if i <= M/N]))

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m = il()

i = 0
ans = 0
for i in range(1, m):
    if m/i < n: break
    if m % i == 0:
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def prime_factorization(n):
    l = [n]
    for i in range(1, ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
    return l

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

p = list(set(prime_factorization(M)))

ans = 1
for i in p:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,input().split())
MR=math.ceil(math.sqrt(M))

LISTM=[]
for i in range(1,MR):
    if M%i==0:
        LISTM.append(i)
        LISTM.append(M//i)
    
LISTM.sort()
LISTM.reverse()

for j in LISTM:
    if j<=M//N:
        print(j)
        break

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def prime_factorization(n):
    l = [n]
    for i in range(1,ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
    return l
N, M = map(int, input().split())

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

p = list(set(prime_factorization(M)))

ans = 1
for i in p:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
import numpy as np

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, min(num // 2, 100000) + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


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

    for num in range(int(math.sqrt(M) + 0.5), 0, -1):
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=[int(s) for s in input().split()]
om=m
fact=[1]
f=2
while m>1:
    if m%f==0:
        m//=f
        fact.append(f)
    f+=1
for i in range(len(fact)):
    if om//fact[i]<n:print(fact[i-1])

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.5)+1):
        if m % i == 0 and i <= m // n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def solve():
    res = 1
    for i in range(2, m//n+1):
        if m % i == 0:
            if (m // i) >= n:
                res = max(res, i)
                break
    print(res)

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.5)+1):
        if m % i == 0 and i <= m/ n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,T  = map(int,input().split())
 
if T % N == 0:
    print (int(T / N))
    exit()
    
while (True):    
    A = int(T - N)
    #print(A)
#    T = int(N / A)
    if A <= 0:
        print(T)
        break
    T = A

Submission status: Wrong Answer

Solution code:
from math import ceil
n, m = map(int, input().split())
for i in range(n, int(m**.5), 1):
    if not m % i:
        print(m//i)
        break
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

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

prime = 1
for i in range(2, int(m ** 0.5)+1):
	if m % i == 0:
		prime = 0
		break

if m % n == 0:
	print(m // n)
elif prime == 1:
	print(1)
# elif m // n > 10**6:
# 	for i in range(n+1, m//n+1):
# 		if m % i == 0:
# 			print(m // i)
# 			break
# else:
# 	for i in range(1, m//n)[::-1]:
# 		amari = m - n*i
# 		if amari % i == 0:
# 			print(i)
# 			break
else:
	for i in range(2, m//n):
		amari = m - n*i
		if amari % i == 0:
			print(i)
			break
		i = m // i
		if m % i == 0:
			print(m // i)
			break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = 2*n
b=n-1
ans = 0

S = 2**b+2*b
if b==0:
    ans=m
elif b==1:
    num=2
else:
    num = 2**b+2*b
if ans==0:
    if m%num==0:
        print(int(m/n))
    else:
        print(m%num)

Submission status: Wrong Answer

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

prime = 1
for i in range(2, int(m ** 0.5)+1):
	if m % i == 9:
		prime = 0

if m % n == 0:
	print(m // n)
elif prime == 1:
	print(1)
# elif m // n > 10**6:
# 	for i in range(n+1, m//n+1):
# 		if m % i == 0:
# 			print(m // i)
# 			break
# else:
# 	for i in range(1, m//n)[::-1]:
# 		amari = m - n*i
# 		if amari % i == 0:
# 			print(i)
# 			break
else:
	for i in range(2, m//n):
		amari = m - n*i
		if amari % i == 0:
			print(i)
			break
		i = m // i
		if m % i == 0:
			print(m // i)
			break

Submission status: Wrong Answer

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

for i in range(2, int(M ** .5) + 1):
    p, q = divmod(M, i)
    if q == 0 and p >= N:
        j = 1
        while p >= N:
            ans = max(ans, i * j)
            p //= N
            j += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        break
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
flag=0
if m %n ==0:
    flag=1
    print(m//n)
else:
    jops=1
    I = m
    s = 0
    R = int(I)
    L=[]
    ansL =[]
    while s == 0:
        #R=int(math.sqrt(R))
        i=2
        while i < R+1:
            if I % i == 0:
                I = I/i
                jops*=i
                ansL.append(jops)
                ansL.append(m//jops)
                if I == 1:
                    L.append(i)
                    s = 1
                    break
            else:
                i+=1
    index =0
    while index < len(ansL):
        if ansL[index] > n-1:
            print(m//ansL[index])
            break
        index+=1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
maxc = M//N
Flag = True
if N == 1:
    print(M)
    flag = False
if Flag:
    while True:
        if M%maxc == 0:
            print(maxc)
            break
        maxc -=1