Problem:


Score : 400 points

Problem Statement

You are given integers N and M.

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

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

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

Sample Input 1

3 14

Sample Output 1

2

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

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000



Sample input:
3 14


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math

def get_divs(a):
	divs = []
	for n in range(1, int(a ** 0.5)):
		if a % n == 0:
			divs.append(n)
			divs.append(a // n)
	return divs

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

	divs = get_divs(M)
	divs.sort()
	divs.reverse()
	divs = filter(lambda x:x <= M // N, divs)

	for div in divs:
		if (M - N * div) % div == 0:
			print(div)
			break

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def divisor(num):
    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 = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
al = []
i = 2


def mul(li):
    a = 1
    for i in li:
        a *= i
    return a


while True:
    if i == m:
        al.sort(reverse=True)
        if n < mul(al):
            while n < mul(al):
                al.pop()
        print(mul(al))
        exit()
    elif m % i == 0:
        al.append(i)
        m //= i
    else:
        i += 1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = 1
i = 2
while True:
    if i == m:
        print(ans)
        exit()
    elif m % i == 0:
        ans *= i
        m //= i
    else:
        i += 1

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)
        if i != n // i and m/n >= (m//i):
            ans = max(ans,m // i)

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)
        if i != n // i and m/n >= (n//i):
            ans = max(ans,n // i)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
div = []
rootM = int(M**0.5)
for i in range(1,rootM + 2):
    if M % i == 0:
        div.append(i)

for j in range(M // N, 0, -1):
    if j in div:
        print(j)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
div = []
for i in range(2,int(M ** 0.5) + 1):
    if M % i == 0:
        div.append(i)

for j in range(M // N, 0, -1):
    if j in div:
        print(j)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
ans = 1
for x in ls:
    if x >= N:
        ans = max(ans, M//x)
        continue
    if M//x >= N:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import sys
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
ans = 1
for x in ls:
    if M//x >= N:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import bisect
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
cur = 1
for x in ls:
    if x > N:
        print(cur)
        sys.exit()
    cur = x
print(cur)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#全探索すると終わらない
import math
N, M = map(int, input().split())
ans = 1
for i in range(1, int(math.sqrt(M + 1)) + 10):
    if M%i == 0:
        if (M//i)//N >= 1:
            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, int(math.sqrt(M + 1))):
    if M%i == 0:
        if (M//i)//N >= 1:
            ans = i
print (ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
  return gcd(b, a%b) if b else a

n, m = list(map(int, input().split()))
if m%n==0:
  print(m//n)
else:
  print(gcd(m//n, m//n+m%n))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
def divisor(n): #約数全列挙
    ans = [1,n]
    i = 2
    while i**2 <= n:
        if n%i == 0:
            ans.append(i)
            if i**2 < n:
                ans.append(n//i)
        i += 1
    ans.sort()
    return ans
if m==n:
    print(1)
    exit()
mlist=divisor(m)[::-1]
for i in range(len(mlist)):
    if mlist[i]<=n:
        print(m//mlist[i-1])
        exit()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
def divisor(n): #約数全列挙
    ans = [1,n]
    i = 2
    while i**2 <= n:
        if n%i == 0:
            ans.append(i)
            if i**2 < n:
                ans.append(n//i)
        i += 1
    ans.sort()
    return ans

mlist=divisor(m)[::-1]
for i in range(len(mlist)):
    if mlist[i]<n:
        print(m//mlist[i-1])
        exit()

Submission status: Wrong Answer

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

for i in range(1, int(M**(1/2))+1):
    if not M % i:
        if i <= n:
            ans = i
        else:
            break

print(ans)

Submission status: Wrong Answer

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

for i in range(1, int(M**(1/2))+1):
    if not M % i:
        if i <= n:
            ans = i

print(ans)

Submission status: Wrong Answer

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

for i in range(1, int(M**(1/2))+1):
    if not M % i:
        if i < n:
            ans = i
        else:
            break
print(ans)

Submission status: Wrong Answer

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

for i in range(1, int(M**(1/2))+1):
    if not M % i:
        if i <= n:
            ans = i
        else:
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

div = []
for m in range(1, int(M ** (0.5) + 1)):
    if M % m == 0:
        div.append(m)
        if m != M // m:
            div.append(M // m)

for i in range(len(div)):
    if div[-i-1] * N <= M:
        print(div[-i-1])
        break

Submission status: Wrong Answer

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

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 // i >= N:
        print(i)
        break
    if M % i == 0 and i >= N:
        print(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 // i >= N:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  if n==100000 and m==1000000000:
    exit()
  sm=1
  for i in range(2,m):
    _m=m-i*(n-1)
    if _m<=0:
      break
    if _m%i==0:
      sm=i

  return sm

print(main())

Submission status: Wrong Answer

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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  if n==100000 and m==1000000000:
    exit()
  sm=1
  for i in range(2,int(math.sqrt(m))+1):
    _m=m-i*(n-1)
    if _m<=0:
      break
    if _m%i==0:
      sm=i

  return sm

print(main())

Submission status: Wrong Answer

Solution code:
import math
def divisor(n):
    res = []
    for i in range(1,int(math.sqrt(n))+2):
        if n % i == 0:
            res.append(i)
            if n / i != i:
                res.append(n / i)
    return res
    
N, M = map(int, input().split())
maxd = 0
for d in divisor(M):
    if M / d >= N:
        maxd = max(maxd, d)
print(maxd)

Submission status: Wrong Answer

Solution code:
import math
def divisor(n):
    res = []
    for i in range(1,int(math.sqrt(n))+1):
        if n % i == 0:
            res.append(i)
            if n / i != i:
                res.append(n / i)
    return res
    
N, M = map(int, input().split())
maxd = 0
for d in divisor(M):
    if M / d >= N:
        maxd = max(maxd, d)
print(maxd)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0:
            j = max(i,M//i)
            if j>=N:
                ans = max(j,ans)

    print(ans)

Submission status: Wrong Answer

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

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0 and M//i>=N:
            ans = i

    print(ans)

Submission status: Wrong Answer

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

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

t = M // N
p = M % N

def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

if p == 0:
    print(t)
else:
    l = [t] * N
    l[-1] += p
    
    x = l[0]
    for i in range(N):
        x = gcd(x, l[i])
        
    print(x)

Submission status: Wrong Answer

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

for i in range(N, 1, -1):
    if M % i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
# abcde    s=input()    s='abcde'
# abcde    s=list(input())    s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)    a=int(input())    a=5
# 1 2    | x,y = s_inpl()   |    x=1,y=2
# 1 2 3 4 5 ... n 　    li = input().split()    li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　    li = inpl()    li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　    li = input().split('T')    li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")
MAX_DIGIT = 50

############
############
############

N, M = l_inpl()

ans = 1

for k in range(1, int(M**0.5)+1):
    if k*N <= M:
        if M % k == 0:
            ans = k
    else:
        break

print(ans)

Submission status: Wrong Answer

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

m = M//N
for i in range(2,m+1)[::-1]:
    if M % i == 0:
        if M//i >= N:
            print(i)
            break
        else:
            print(1)

Submission status: Wrong Answer

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

m = M//N
for i in range(2,m)[::-1]:
    if M % i == 0:
        if M//i >= N:
            print(i)
            break
        else:
            print(1)
            break

Submission status: Wrong Answer

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

if M % N == 0:    print(M//N)
else:
    m = M//N
    for i in range(2,m)[::-1]:
        if M % i == 0:
            if M//i >= N:
                print(i)
                break
            else:
                print(1)
                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 m/i>=n:
            ans=max(ans,i)
        elif i>=n:
            ans=max(ans,m//i)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
#m%g=0 and m>=g*nが成立 降順にすれば一発目が答え
ans=1
for i in range(m//n+1,0,-1):
    if m%i==0:
        ans=i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import bisect
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int):
    ds = [1]
    for i in range(2, int(ceil(sqrt(M)))):
        if M % i == 0:
            ds.append(i)
  
    th = M // N
    return ds[bisect.bisect(ds, th)-1]


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil, sqrt

N, M = map(int, input().split())
ans = 0
for i in range(1, ceil(sqrt(M))):
  if M % i==0:
    if i >= N:
      ans = max(ans, M//i)
    if M//i >= N:
      ans = max(ans, i)
      
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil, sqrt

N, M = map(int, input().split())
ans = 0
for i in range(2, ceil(sqrt(M))):
  if M % i==0:
    if i >= N:
      ans = max(ans, M//i)
    if M//i >= N:
      ans = max(ans, i)
      
print(ans)

Submission status: Wrong Answer

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

if N==1:
  print(M)
  tmp=1
else:
  for i in range(int(M**0.5)+1000):
    k = i + N
    if M % k == 0:
      print(int(M/k))
      tmp=1
      break

if tmp==0:
  print(1)

Submission status: Wrong Answer

Solution code:
import math
a_list = []
n, m = map(int, input().split())
for i in range(math.ceil(m**(1/2)), 0, -1):
    if m % i == 0:
        a_list.append(i)
border = math.floor(m / n)
for aa in a_list:
    if border >= aa:
        ans = aa
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
k = math.floor(m / n)
for i in range(min(k, math.floor(m**(1/2))), 0, -1):
    if m % i == 0:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,M = map(int,input().split())
a = []
for i in range(math.floor(M**0.5)):
    if M%(i+1) == 0:
        a.append(i+1)
for i in range(len(a)-1,-1,-1):
    a.append(int(M/a[i]))
tmp = 0
for i in a:
    if i > M/N:
        print(tmp)
        break
    else:
        tmp = i

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 and i <= m/n:
        if ans < i:
            ans = i

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  if M % i == 0 and M >= i * N:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import collections

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

div = collections.deque()
div2 = collections.deque()
for i in range(1, int(M**0.5)+1):
  if M % i == 0:
    div.append(i)
    if M // i != i:
      div2.appendleft(M // i)
div.extend(div2)

for i in range(len(div)):
  num = div.popleft()
  if num > N:
    print(M // num)
    break

Submission status: Wrong Answer

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


def make_divisors(n):
    if n == 1:
        return [1]

    i, divisors = 2, [1]
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
        i += 1
    divisors.append(n)
    return divisors


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

Submission status: Wrong Answer

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


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


factors = factorize(M)
n_factors = len(factors)

ans = 0
for i in range(1 << n_factors):
    x = 1
    for j in range(n_factors):
        if i & (1 << j):
            x *= factors[j]
    y = M // x
    print(x, y, N <= y)
    if N <= y:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

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


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


factors = factorize(M)
ans = 0
for i in range(1, 1 << len(factors)):
    x = 1
    for j in range(len(factors)):
        if i & (1 << j):
            x *= factors[j]
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

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

i = 1
ans = 1
while i * i <= m:
  if m % i == 0:
    if i >= n:
      if i >= n:
        ans = max(ans, m // i)
      elif m // i >= n:
        ans = max(ans(ans, i))
        
  i += 1
  
  
print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

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

i = 1
ans = 0
while i  <= m // n and i * i <= m:
  if m % i == 0:
    ans = i
  i += 1
  
  
print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i  <= m // n and i * i <= m:
    if m % i == 0:
      ans = i
    i += 1
    
    
  print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i  <= m // n and i * i <= m:
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1
    
    
  print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i * i  <= m:
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1

  print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i * i  <= m:
    if (m - i * n) % i == 0:
      ans = i
      break
    i += 1

  print(ans)

Submission status: Wrong Answer

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  ans = 0
  for i in range(1, m//n):
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1
  print(ans)

Submission status: Wrong Answer

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

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

else:
  i = 2
  ans = 0
  while i * n <= m:
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1

  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def factoring(n: int):
    factors = []
    p = 1
    while p * p <= n:
        if n % p == 0:
            factors.append(p)
            if n != p * p:
                factors.append(n // p)
        p += 1
    return factors

def solve(N: int, M: int):
    if N == 1:
        print(M)
        return
    F = factoring(M)
    F.sort()
    print(F)
    for f in F:
        if f >= N:
            print(M // f)
            break
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
ans = 1
for k in range(1, math.ceil(math.sqrt(m))):
    l = m / k
    if m % k == 0 and n * k <= m:
        ans = max(k, ans)
    if m % l == 0 and n * l <= m:
        ans = max(l, ans)
print('%d' % ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
ans = 1
for k in range(1, math.ceil(math.sqrt(m))):
    if m % k == 0 and n * k <= m:
        ans = max(k, ans)
print('%d' % ans)

Submission status: Wrong Answer

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

# Mの約数dのうち、Nd <= Mとなるものの最大

divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    if M%d == 0:
        divisors.append(d)
        divisors.append(M//d)

ans = 1

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Submission status: Wrong Answer

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

# Mの約数dのうち、Nd <= Mとなるものの最大

divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    divisors.append(d)
    divisors.append(M//d)

ans = 1

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Submission status: Wrong Answer

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

n, m = nm()
ans = 0
for i in range(2, int(math.sqrt(m)) + 2):
    if m % i == 0:
        if m // i >= n and i >= n:
            ans = max(ans, i, m // i)
        elif m // i >= n:
            ans = max(ans, i)
        elif i >= n:
            ans = max(ans, m // i)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n, m = nm()
ans = 1
for i in range(2, math.ceil(math.sqrt(m)) + 1):
    if m % i == 0:
        ans = max(i, m // i)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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