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:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう

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


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


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    # 要はx以下で最大のmの約数
    lis = sorted(enum_divisor(m), reverse=True)
    for l in lis:
        if l <= x:
            print(l)
            exit()

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


def enum_divisor(n):
    ret = []
    for i in range(1, int(n**0.5)):
        if n % i == 0:
            ret.append(i)
    return ret


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    # 要はx以下で最大のmの約数
    lis = sorted(enum_divisor(x), reverse=True)
    for l in lis:
        if l <= x:
            print(l)
            exit()

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


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


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    # 要はx以下で最大のmの約数
    lis = sorted(enum_divisor(x), reverse=True)
    for l in lis:
        if l <= x:
            print(l)
            exit()

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


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


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    # 要はx以下で最大のmの約数
    lis = enum_divisor(x)
    print(lis[-1])

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


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


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    # これが遅い 要はx以下で最大のmの約数
    print(gcd(x, m))

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


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, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


if m % n == 0:
    print(m // n)
    exit()
else:
    lis = make_divisor_list(m)
    lis = sorted(lis, reverse=True)
    for l in lis:
        if (m // n) % l == 0:
            print(l)
            exit()

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    x = m // n
    for i in range(x, 0, -1):
        if m % i == 0:
            print(i)
            exit()
print(1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m % n == 0:
    print(m//n)
    exit()
ans = 1
for i in range(int(m**(0.5))+1,1,-2):
    while m % i == 0:
        if m //i >= n:
            m //= i
            ans *= i
        else:
            break
while m % 2 == 0:
    if m //2 >= n:
        m //= 2
        ans *= 2
    else:
        break
print(ans)

Submission status: Wrong Answer

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

for i in range(n,m):
    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(2,int(m**0.5)+1):
    if m%i==0:
        x = m//i
        if x>=n:
            ans = max(ans,i)
        if i>=n:
            ans = max(ans,x)
        
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)+1):
    if m%i==0:
        x = m//i
        if x>=n:
            ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = 0
for i in range(1,min(m//n,m//2)+1):
    if m%i==0:
        x = m//i
        if x>=n:
            ans = i
print(ans)

Submission status: Wrong Answer

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

a,b = map(int, input().split())
l = make_divisors(b)
l.sort(reverse=False)
res = 1
#print(l)
for x in l:
    if x < a:
        continue
    xx = b // x
    if xx <= a:
        res = max(xx, res)
print(res)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N,M = LMIIS()
    for i in range(int(M**0.5),-1,-1):
        if M % i == 0:
            if M //i >= N:
                print(i)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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 and m//i>=n:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    d = [1]
    for i in range(2, int(m ** 0.5) + 1):
        if m % i == 0:
            d.append(i)

    v = m / n
    ans = max(i for i in d if i <= v)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if gcd(n, m) == 1:
        print(1)
        exit()

    l = int(m / n)
    for i in range(l, 1, -1):
        p, q = divmod(m, i)
        if q != 0 or p < n:
            continue

        print(i)
        break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if N == 1:
    print(M)
else:
    d = 1
    ds = []
    while d ** 2 <= M:
        if M % d == 0:
            ds.append(d)
        d += 1
    ds.sort(reverse=True)
    for d in ds:
        if N * d <= M:
            print(d)
            break

Submission status: Wrong Answer

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

if N == 1:
    print(M)
else:
    d = 1
    ds = []
    while d ** 2 <= M:
        if M % d == 0:
            ds.append(d)
        d += 1
    ds.sort(reverse=True)
    for d in ds:
        if N <= M // d:
            print(d)
            break

Submission status: Wrong Answer

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

d = 1
ds = []
while d ** 2 <= M:
    if M % d == 0:
        ds.append(d)
    d += 1
ds.sort(reverse=True)
for d in ds:
    if N <= M // d:
        print(d)
        break

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    N, M = MI()

    ans = 1
    for i in range(2, int(pow(M, 0.5))+1):
        if M % i: continue
        j = M // i

        if i * N <= M: ans = max(ans, i)
        if j * N <= M: ans = max(ans, j)
    print(ans)




if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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


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

div = make_divisors(num=m)

ans = 0
for x in div:
    if x*n <= m:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,m=n1()

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

    divisors.sort()
    return divisors

if m%n==0:
    print(m//n)
else:
    div=make_divisors(m)
    i=bisect_right(div,n)
    print(div[i-1])

Submission status: Wrong Answer

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())

ans = 0
div1,div2 = [],[]
for m in range(1,int(M**.5)+1):
    if M%m == 0:
        div1.append(m)

for d in div1:
    if M%d == 0:
        div2.append(M//d)

for d in div1+div2:
    if d <= M//N:
        ans = d

print(ans)

Submission status: Wrong Answer

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())

ans = 0
div1,div2 = [],[]
for m in range(1,int(M**.5)+1):
    if M%m == 0:
        div1.append(m)

for d in div1:
    if M%d == 0:
        div2.append(M//d)

for d in div1+div2:
    if d < M//N:
        ans = d

print(ans)

Submission status: Wrong Answer

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())

ans = 0
for m in range(1,int(M**.5)+1):
    if M%m == 0 and m <= M//N:
        ans = m

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
div = m//n+1
INF = 10**18
ans = -INF
for i in range(1, div+1):
    if m % i == 0:
        ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

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

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

print (ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for i in range(1,math.ceil(math.sqrt(m))):
	x = i*n
	y = m-x
	if y < 0:
		break
	if y % i == 0 and m%i == 0:
		ans = i
print (ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
 
ans = 0
for i in range(1,math.ceil(math.sqrt(10**9))):
	x = i*n
	y = m-x
	if y < 0:
		break
	if y % i == 0:
		ans = i
	else:
		continue
print (ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
 
ans = 0
for i in range(1,math.ceil(math.sqrt(m))):
	x = i*n
	y = m-x
	if y < 0:
		break
	if y % i == 0:
		ans = i
	else:
		continue
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))):
	x = i*n
	y = m-x
	if y < 0:
		break
	if y % i == 0:
		ans = i
	else:
		continue
print (ans)

Submission status: Wrong Answer

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

ans = 1
for i in range(1,10**5):
	x = i*n
	y = m-x
	if y < 0:
		break
	if y % i == 0:
		ans = i
	else:
		continue
print (ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n, m = map(int, input().split())
d = divisor(m)
for i in range(len(d)):
    if d[i] > int(m/n): break
print(d[i-1])

Submission status: Wrong Answer

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

n, m = map(int, input().split())
d = divisor(m)
for i in range(len(d)):
    if d[i] > m/n: break
print(d[max(i-1, 0)])

Submission status: Wrong Answer

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

n, m = map(int, input().split())
d = divisor(m)
for i in range(len(d)):
    if d[i] > m/n: break
print(d[i-1])

Submission status: Wrong Answer

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

    for i in range(n, 0, -1):
        if m % i == 0 and n*i <= m:
            print(i)
            return
    print(1)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

ans = 1
for d in ds:
    if d <= N:
        ans = max(ans, d)
print(ans)

Submission status: Wrong Answer

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

    for i in range(n, 0, -1):
        if m % i == 0:
            print(i)
            return
    print(1)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
n,m = map(int, input().split())
r,q= divmod(m,n)
print(fractions.gcd(r,r+q))

Submission status: Wrong Answer

Solution code:
import math
import sys
MOD = 1000000007

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

if n == 1:
    print(m)
    sys.exit()

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
import sys
MOD = 1000000007

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

if n == 1:
    print(m)
    sys.exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
MOD = 1000000007

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

if n == 1:
    print(m)
    sys.exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


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

        # divisors.sort(reverse=True)
        return divisors

    n, m = ns()
    gcd = make_divisors(m)

    max_gcd = 1
    for d in gcd:
        if m // d >= n:
            max_gcd = max(max_gcd, d)

    print(d)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


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

def main():
    N, M = map(int, input().split())
    divisors = make_divisors(M)
    while True:
        d = divisors.pop()
        if M >= N * d:
            print(d)
            return




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
result = 1
for i in range(int(m**0.5), 1, -1):
    if m % i == 0:
        j = m // i
        if i >= n:
            result = max(result, j)
        elif j >= n:
            result = max(result, i)
print(result)

Submission status: Wrong Answer

Solution code:
from math import floor
N,M=map(int,input().split())
p= floor(M**0.5)
kumi=[]

for i in range(1,p+1):
  if M%i==0:
    kumi.append((i,M//i))
    
for pair in reversed(kumi):
  if pair[1]>=N:
    print(pair[0])
    exit()

Submission status: Wrong Answer

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

ans = 0

for i in range(1, (m//n)+1):
    all = 0
    if m % i == 0:
        for j in range(1,n+1):
            all += i**j
            if all > m: break
            print(i, j, all)
        if all == m: ans = i

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split()) 
import math
x = M//N
y = int(math.sqrt(M))
if y < x:
  x = y
  
for i in range(-x,2):
  if M%(-i)==0:
    print(-i)
    break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split()) 
import math
x = int(math.floor(M/N))
y = int(math.sqrt(M))
if y < x:
  x = y
  
for i in range(-x,0):
  if M%(-i)==0:
    print(-i)
    break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split()) 
import math
x = math.floor(M/N)
y = int(math.sqrt(M))
if y < x:
  x = y
for i in range(-x,0):
  if M%(-i)==0:
    print(-i)
    break

Submission status: Wrong Answer

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

ans = 1
for x in range(1, 10 ** 5 + 10):
    if M % x == 0:
        if N * x <= M:
            ans = max(ans, x)

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split()) 
import math
x = math.floor(M/N)
for i in range(-x,-x//2+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(2,int(m**0.5)+1):
  if m%i==0:
    x=i
    y=m//i
    if m//i>=n and ans<i:
      ans=i
    if m//y>=n and ans<y:
      ans=y
print(ans)

Submission status: Wrong Answer

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

    # divisors.sort()
    return divisors

N, M = map(int, input().split())
print(max([x for x in make_divisors(M) if x <= N]))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ans=1
for i in range(2,10**4+1):
  if m%i==0:
    if m//i>=n:
      ans=i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

sq = math.sqrt(M)
sq = math.floor(sq)


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

Submission status: Wrong Answer

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

sq = math.sqrt(M)
sq = math.floor(sq)

for i in range(1,sq+2):
  if M % i == 0:
    if i * N <= M:
      ans = i
if N == 1:
  print(int(M))
else:
  print(int(ans))

Submission status: Wrong Answer

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

sq = math.sqrt(M)
sq = math.floor(sq)

for i in range(1,sq+2):
  if M % i == 0:
    if i * N <= M:
      ans = i
    
print(int(ans))

Submission status: Wrong Answer

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

sq = math.sqrt(M)
sq = math.floor(sq)

for i in range(1,sq+2):
  if M % i == 0:
    if i <= math.floor(M/N):
      ans = i
    
print(int(ans))

Submission status: Wrong Answer

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

sq = math.sqrt(M)
sq = math.floor(sq)

for i in range(1,sq+1):
  if M % i == 0:
    if i <= math.floor(M/N):
      ans = i
    
print(int(ans))

Submission status: Wrong Answer

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

if M % N != 0:
  
  a = int(M % N)
  b = (M - a) / N
  c = fractions.gcd(a, b)
  print(int(c))
else:
  print(int(M/N))

Submission status: Wrong Answer

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

if M % N != 0:
  print(int(M % N))
else:
  print(int(M/N))

Submission status: Wrong Answer

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

for i in range(1, int(m**0.5)+1)[::-1]:
    if (m % i == 0) and (m / n >= i):
        print(max(i, m // i))
        break

Submission status: Wrong Answer

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

for i in range(1, int(m**0.5)+1)[::-1]:
    if (m % i == 0) and (m / n >= i):
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(int(m ** 0.5) + 1)[::-1]:
    if (m % i == 0) and (m // i >= n):
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n, m = MII()
    divs = enumerate_divs(m)
    ans = []
    h = m/n
    for i,j in divs:
        if i <= h:
            ans.append(i)
        if j <= h:
            ans.append(i)
    print(max(ans))


if __name__ == '__main__':
    main()