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:
n,m=map(int,input().split())

yakusuu=[]
import math
for i in range(1,int(math.sqrt(m)+1)):
  if m%i==0:
    yakusuu.append(i)
    yakusuu.append(m//i)
yakusuu.sort()
for num in yakusuu:
  if num>=n:
    print(num)
    exit()

Submission status: Wrong Answer

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

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

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

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

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = na()
MAX = M // N
ans = 1

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

if M % N == 0:
    print(M // N)
else:
    tmp = make_divisors(M)
    print(tmp[bisect.bisect_left(tmp, MAX) - 1])

Submission status: Wrong Answer

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

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

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = na()
if M % N == 0:
    print(M // N)
    sys.exit()

print(math.gcd(M % N, M % N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
di = []
for i in range(1, int(m**0.5)+1):
  if m % i == 0:
    di.append(i)
    if i != m // i:
      di.append(m//i)
di.sort()
l = 0
r = len(di)-1
a = m//n
while(l<r):
  mi = (l+r)//2
  if di[mi] >= a:
    r = mi
  else:
    l = mi+1
print(di[r-1])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
di = []
for i in range(1, int(m**0.5)+1):
  if m % i == 0:
    di.append(i)
    if i != m // i:
      di.append(m//i)
di.sort()
l = 0
r = len(di)-1
a = m//n
while(l<r):
  mi = (l+r)//2
  if di[mi] > a:
    r = mi
  else:
    l = mi+1
print(di[r-1])

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if M % N == 0:
        print(M // N)
    else:
        print(M % N)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if x > n:
        break
    ans = x
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
fact = []
if m % n == 0:
    print(m // n)
    exit()
ans = 1
for i in range(1, 40000):
    if m % i == 0:
        if m >= n * i:
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
fact = set([])
if m % n == 0:
    print(m // n)
    exit()
for i in range(1, 40000):
    if m % i == 0:
        fact.add(i)
        fact.add(m // i)
ans = 1
for x in sorted(fact):
    if x > n:
        break
    ans = x
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
fact = []
if m % n == 0:
    print(m // n)
    exit()
ans = 1
for i in range(1, 40000):
    if m % i == 0:
        if m // i >= n:
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
fact = []
if n == 1:
    print(m)
    exit()
ans = 1
for i in range(1, 40000):
    if m % i == 0:
        if m // i >= n:
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
fact = []
ans = 1
for i in range(1, 40000):
    if m % i == 0:
        if m // i >= n:
            ans = i
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
for i in range(min(M//N,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())
l,r=0,M//N+1
while l+1!=r:
  x=(l+r)//2
  if M%x==0:
    l=x
  else:
    r=x
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    # M = a*b b >= N
    i = 1
    max_gcd = 1
    while i*i <= M:
        if M%i == 0 and M//i >= N:
            max_gcd = i
        i += 1
    return max_gcd


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

Submission status: Wrong Answer

Solution code:
from math import gcd

n, m = map(int, input().split())
print(gcd(*divmod(m, n)))

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,M = i_map()
    ans = 0
    if N == 1:
        print(M)
        exit()
    for i in range(2,10**5+1):
        k = i*(N-1)
        j = M-k
        if j <= 0:
            break
        ans = max(ans,gcd(k,j))
        if i >= M:
            break
    print(ans)


if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,M = i_map()
    ans = 0
    for i in range(1,10**5+1):
        k = i*(N-1)
        j = M-k
        if j <= 0:
            break
        ans = max(ans,gcd(k,j))
        if i >= M:
            break
    print(ans)


if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,M = i_map()
    ans = 0
    for i in range(1,10**5+1):
        k = i*(N-1)
        j = M-k
        if j <= 0:
            break
        ans = max(ans,gcd(k,j))
        if i == M:
            break
    print(ans)



if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

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

    # divisors.sort()
    return divisors

ans = 1
for i in make_divisors(M):
    work1 = i * (N - 1)
    work2 = M - work1
    if work2 > 0 and work2 % i == 0:
        ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for i in range(2,10**5):
    if m%i == 0:
        v = i
        cnt = m//i
        if cnt >= n:
            ans = max(ans,v)

        v = m//i
        cnt = i
        if cnt >= n:
            ans = max(ans,v)

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

Submission status: Wrong Answer

Solution code:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

for i in range (1, math.floor(M**0.5)+1):
	if M%i == 0:
		A.append(i)
        
A = A[::-1]

for i in range (0, len(A)):
	if A[i]*N <= M:
		print(A[i])
		exit()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left,bisect

# ===================================== 約数のリスト   
def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

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

div=enum_div(m)
div.sort(reverse=True)

rd=[0]*len(div)
for i in range(len(div)):
    rd[i]=m//div[i]

mm=bisect_left(rd,n)

print(div[mm])

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
def prime_factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr

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

if m%n==0:
    print(m//n)
else:
    arr = prime_factorization(m)
    for i in arr:
        if i[0] >= n:           
            print(m//i[0])
            break
    else:
        maxi = m/n
        for i in arr:
            if i[0] > maxi:
                print(m//arr[arr.index(i)-1][0])
                exit()

Submission status: Wrong Answer

Solution code:
from copy import *
n,m=map(int,input().split())
t=deepcopy(n)
while True:
    if m%t==0:
        if t*n<=m:
            print(t)
            exit()
        else:
            t-=1
    else:
        t-=1

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
while True:
    if m%n==0:
        print(n)
        exit()
    else:
        n-=1

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))+1):
  if m%i==0:
    if m//i < m//n + 1:
      ans = m//i
    elif i < m//n+1:
      ans = i
    else:
      break
print(ans)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

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

a = factorization(m)
con = 10**9
for i in range(len(a)):
    for j in range(1,a[i][1]+1):
        if a[i][0]**j >= n:
            con = min(con,a[i][0]**j)
b = factorization(con)
for i in range(len(a)):
    if a[i][0] == b[0][0]:
        a[i][1] -= b[0][1]
ans = 1
for i in range(len(a)):
    ans *= (a[i][0]**a[i][1])
print(ans)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n,m = map(int,input().split())
if m % n == 0:
    ans = m//n
else:
    a = factorization(m)
    con = 10**9
    for i in range(len(a)):
        for j in range(1,a[i][1]+1):
            if a[i][0]**j > n:
                con = min(con,a[i][0]**j)
    b = factorization(con)
    for i in range(len(a)):
        if a[i][0] == b[0][0]:
            a[i][1] -= b[0][1]
    ans = 1
    for i in range(len(a)):
        ans *= (a[i][0]**a[i][1])
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    search = M//N + 1
    for s in range(search, 0, -1):
        sum_array = s * N
        remain = M - sum_array
        if remain % s == 0:
            print(s)
            return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if M%N==0:
    print(mn)
else:
    print(math.gcd(mn,ml))

Submission status: Wrong Answer

Solution code:
import sys
def factors(n):
  a = []
  x = 1
  while x * x <= n :
    if n % x == 0:          
      a.append(x)
      a.append(n//x)
    x += 1
  return a
n,m=map(int,input().split())
fac=factors(m)
for i in range(len(fac)-1,-1,-1):
  if n*fac[i]<=m:
    print(fac[i])
    sys.exit()

Submission status: Wrong Answer

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

cand = []

for i in range(2, int(sqrt(M))+1):
    if M % i == 0:
        cand.append(i)
        u = M // i
        if u != i:
            cand.append(u)

cand.sort()

ans = 1
for j in cand:
    if N * j <= M:
        ans = max(ans, j)

print(ans)

Submission status: Wrong Answer

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

cand = []

for i in range(2, int(sqrt(M))+1):
    if M % i == 0:
        cand.append(i)
        cand.append(M//i)

cand.sort()

ans = 1
for j in cand:
    if N * j <= M:
        ans = j

print(ans)

Submission status: Wrong Answer

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

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

t = M // N

n = 2
p = []
while n <= t:
    if all(n%i != 0 for i in p):
        p.append(n)
    n += 1

if len(p) == 0:
    print(1)
    exit(0)

mxp = -1
for i in p:
    if M % i == 0:
        mxp = i

if mxp == -1:
    print(1)
    exit(0)

tt = M // mxp
# print(mxp)
# print(tt)
if tt % N == 0:
    print(mxp * tt//N)
else:
    print(gcd(mxp*tt//N, mxp*(tt//N+1)))

Submission status: Wrong Answer

Solution code:
def divisor(n):
    i = 1
    res = []
    while i*i <= n:
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
        i += 1
    res.sort()
    res.pop()
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n==1:print(m);exit()
for i in range(1,int(m**.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 n==1:print(m);exit()
for i in range(1,int(m**.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(1,int(m**.5)+2)[::-1]:
    if m%i==0 and m/n>=i:print(i);break

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

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

    # Mの約数の中でMを割った時の値がN以上になるような最大のもの
    ans = 1
    for i in M_div:
        if M // i >= N:
            ans = i

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

    # Mの約数の中でMを割った時の値がN以上になるような最大のもの
    ans = 1
    for i in range(1, min(M // N + 1, int(M ** 0.5) + 1)):
        if M % i == 0:
            ans = i

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

import math
G=[]
for i in range(1,int(math.sqrt(M))+2+1):
    if M%i == 0:
        cd = M/i
        G.append(cd)
        G.append(i)

G.sort(reverse=True)
for g in G:
    n = M/g
    if n>=N:
        print(g)
        exit()

Submission status: Wrong Answer

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

if m%n ==0: print(m//n)
else:
    x,y = m//n, m//n+m%n
    print(math.gcd(x,y))

Submission status: Wrong Answer

Solution code:
from math import sqrt
from numba import njit
@njit
def divisors(n):
    divisors = []
    for i in range(1, int(sqrt(n))+1):
        q, r = divmod(n, i)
        if r == 0:
            divisors.append(i)
            if i != q:
                divisors.append(q)
    divisors.sort()
    return divisors

n, m = map(int, input().split())
ans = 1
for a in divisors(m)[1:-1]:
    if a*n <= m:
        ans = a
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
# for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
#   if M % i == 0:
#     if M // i <= M//N:
#       print(max(i, M // i))
#     else:
#       print(i)
#     break

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

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
# for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
#   if M % i == 0:
#     if M // i <= M//N:
#       print(max(i, M // i))
#     else:
#       print(i)
#     break

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

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
# for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
#   if M % i == 0:
#     if M // i <= M//N:
#       print(max(i, M // i))
#     else:
#       print(i)
#     break

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

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
# for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
#   if M % i == 0:
#     if M // i <= M//N:
#       print(max(i, M // i))
#     else:
#       print(i)
#     break

ans = 1
for i in range(2, math.floor(M**0.5)+1):
  if M % i == 0:
    if i <= M//N and M // i <= M//N:
      ans = max(ans, i, M//N)
    elif 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:
import math
N, M = [int(i) for i in input().split()]
for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
  if M % i == 0:
    if M // i <= M//N:
      print(max(i, M // i))
    else:
      print(i)
    break

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
for i in range(min(math.ceil(math.sqrt(M)), M//N), 0, -1):
  if M % i == 0:
    print(i)
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
for i in range(math.ceil(M/N)+1, 0, -1):
  if M % i == 0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import math
N, M = [int(i) for i in input().split()]
for i in range(math.ceil(M/N)+1, 1, -1):
  if M % i == 0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()

def primes(n): #試し割り法で各素因数とその指数を求める
    cnt=collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            while n%i==0:
                cnt[i]+=1
                n//=i
    if n!=1:
        cnt[n]+=1
    return cnt

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

divs = make_divisors(M)

for i, divisior in enumerate(divs):
    if divisior > M // N:
        break

print(divs[i - 1])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
li = []
#mの約数を求める
for i in range(int(m**0.5) + 1, 0, -1):
    if i == int(m**0.5)+1 and (i-1)**2 == m:
        continue
    if m%i==0:
        li.append(i)
#
for i in li:
    if n <= m//i:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
li = []
for i in range(int(m**0.5) + 1, 0, -1):
    if m%i==0:
        li.append(i)
for i in li:
    if i <= m//n:
        print(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)+1):
    if i > m/n:
        break
    else:
        if m%i==0:
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=1
for i in range(2,4*10000):
    if M%i:
        continue
    if M//i>=N and i>a:
        a=i
    if i>=N and M//i>a:
        a=M//i
print(a)

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
for i in range(len(b)):
    if i * n <= m:
        a.append(i)
        print(max(a))

if len(b) == 2:
    print(1)
else:
    print(max(a))

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        a.append(i)
#print(b)
if len(b) == 2:
    print(1)
else:
    print(max(a))

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        a.append(i)
#print(b)
if b == m:
    print(1)
else:
    print(max(a))

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        a.append(i)
#print(b)
print(max(a))

Submission status: Wrong Answer

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

if m//n == m/n:
    print(m//n)
else:
    ans = 1
    for i in range(2,min(m,10**7+1)):
        if m-i*(n-1) < i:
            break
        if m%i == 0:#from (M-i*(N-1))%i==0
            ans = i
    print(ans)

Submission status: Wrong Answer

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

if m//n == m/n:
    print(m//n)
else:
    ans = 1
    for i in range(2,min(m,10**5+1)):
        if m-i*(n-1) < i:
            break
        if m%i == 0:#from (M-i*(N-1))%i==0
            ans = i
    print(ans)

Submission status: Wrong Answer

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

def f(n,m):
	divisors = []
	for d in range(2, int(m ** 0.5)+1)[::-1]:
		if m % d == 0:
			divisors.append(d)
			if d != m/d: divisors.append(m/d)
	divisors.sort(key = lambda x:-x)
	for d in divisors:
		if m/d >= n:
			return d

	return 1

print f(n,m)

Submission status: Wrong Answer

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

def f(n,m):

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

	return 1

print f(n,m)

Submission status: Wrong Answer

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

def f(n,m):

	for d in range(2, int(m ** 0.5) + 1):
		if m % d == 0:
			if m / d >= n:
				return d		
				break

	return 1

print f(n,m)

Submission status: Wrong Answer

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

max_ = 0
for n in range(N + 1, 0, -1):
    d = (M - N * n)

    if d >= 0 and d % n == 0:
        max_ = n
        break

print(max_)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from bisect import bisect_left

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


t = M
#約数全列挙
sep = [1]
for i in range(2,int(sqrt(M))+2,1):
    if M % i ==0:
        count = 0
        if M % i == 0:
            if N <= i and i <= t:
                t = i
            if N <= M//i and M//i <= t:
                t = M//i

print(M//t)