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,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()

  if n==1:
    return m

  a=0
  for i in range(2,int(math.sqrt(m))+1):
    if m%i==0 and i*n<=m:
      a=max(a,i)
      if m//i*n<=m:
        a=max(a,m//i)

  return a

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()

  a=0
  for i in range(2,int(math.sqrt(m))+1):
    if m%i==0 and i*n<=m:
      a=i

  return a

# main()
print(main())

Submission status: Wrong Answer

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

if m%n==0:
    print(m//n)
    exit()
temp=m//n
left=m-temp*n
gcd=fractions.gcd(temp,temp+left)
print(gcd)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
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
li = make_divisors(m)
point = 1
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
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
li = make_divisors(m)
point = 1
for i in li:
    if i > n:
        break
    m //= i
    point = i
print(point)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
p = []
tmpm = m
for i in range(2, m):
  if tmpm % i == 0:
    while tmpm % i == 0:
      tmpm = tmpm // i
      p.append(i)
setp = set(p)
maxans = 1
for i in setp:
  if p.count(i) >= n:
    maxans = max(maxans, i)
print(maxans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if M%N==0:
    print(M//N)
else:
    from math import sqrt, floor
    print(floor(sqrt(M//N)))

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

result = 1
for i in range(2, int(sqrt(M)) + 1):
    if M % i != 0:
        continue
    t = M // i
    if t >= N:
        result = max(result, i)
    if M // t >= N:
        result = max(result, t)
print(result)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,input().split())
m=0
i=1
while math.sqrt(M)>=i and M//N>=i:
    if M%i==0:
        m=i
    i=i+1
print(m)

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = [int(_) for _ in input().split()]
m = M

a = 1
flg = False
for i in range(2, int(sqrt(M)) + 1):
    if M % i==0:
        if i <= M / N:
            a = max(a, i)
        b = M // i
        if b <= M / N:
            a = max(a, b)

print(a)

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = [int(_) for _ in input().split()]
m = M

a = 1
flg = False
for i in range(2, int(sqrt(M)) + 1):
    if i <= M / N:
        a = max(a, i)
    b = M // i
    if b <= M / N:
        a = max(a, b)

print(a)

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = [int(_) for _ in input().split()]
m = M

a = 1
flg = False
for i in range(2, int(sqrt(M)) + 1):
    if i > M/N: break
    if M % i==0:
        a = i

print(a)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

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

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

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

Submission status: Wrong Answer

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

ans = 1

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

import math

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

print(max(l))

Submission status: Wrong Answer

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

ans = 1

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

import math
for i in range(int(math.sqrt(M)), 0, -1):
    if M % i == 0 and i * N <= M:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

ans = 1
import math
for i in range(int(math.sqrt(M)), 0, -1):
    if M % i == 0 and i * N <= M:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 1
import math
for i in range(1, int(math.sqrt(M))):
    if N * i > M:
        break
    if M % i == 0:
        ans = i

print(ans)

Submission status: Wrong Answer

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

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=0
table=make_divisors(M)
table.sort()

for i in table:
    if i<=M//N+1:
        ans=i
        
print(ans)

Submission status: Wrong Answer

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

ans=0
for i in range(1,N+1):
    if M%i==0:
        ans=max(ans,i)
        
print(ans)

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  
  mx=1
  for i in range(2,int(math.sqrt(b))+100):
    if b%i==0:
      if i*a<=b:
        mx=i
  return mx

# main()
print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  
  mx=1
  for i in range(2,int(math.sqrt(b))+100):
    if b%i==0:
      if i*a<=b:
        mx=i
      else:
        return mx
  return mx

# main()
print(main())

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  
  mx=1
  for i in range(2,int(math.sqrt(b)+2)):
    if b%i==0:
      if i*a<=b:
        mx=i
      else:
        return mx
  return mx

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import bisect
def make_divisort(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(bisect.bisect_left(make_divisort(M), M//N))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
cnt = M // N
M -= N * cnt
ans = 1
while True:
    if cnt == 1:
        ans = cnt
        break
    if M == 0:
        ans = cnt
        break
    tmp = gcd(cnt, M)
    if tmp != 1:
        ans = min(cnt, tmp)
        break
    M += N
    cnt -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
cnt = M // N
M -= N * cnt
ans = 1
while True:
    if M == 0:
        ans = cnt
        break
    tmp = gcd(cnt, M)
    if tmp != 1:
        ans = min(cnt, tmp)
        break
    M += N
    cnt -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
quotient = M // N
cnt = quotient - 2
M -= N * cnt
while True:
    if M < N:
        break
    cnt += 1
    M -=  N

if M % cnt == 0:
    ans = cnt
else:
    ans = M % cnt

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split(" "))
    for i in range(M // N, 1, -1):
        if M % i == 0 and i <= M / N:
            print(i)
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split(" "))
    i = 2
    result = 0
    while i * i <= M:
        if M % i == 0:
            if i <= M / N:
                result = i
            else:
                break
        i += 1
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split(" "))
    i = M // N
    while True:
        if M % i == 0:
            break
        elif i == 2:
            break
        else:
            i -= 1
    print(i)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split(" "))
    i = M // N + 1
    while True:
        if M % i == 0:
            break
        elif i == 2:
            break
        else:
            i -= 1
    print(i)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import sqrt


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

ans = 1
for i in range(1, int(sqrt(M)) + 1):
    if M % i == 0 and M / N >= i:
        ans = i

if N == 1:
    ans = M

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt


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

ans = 1
for i in range(1, int(sqrt(M))):
    if M % i == 0 and M / N >= i:
        ans = i

if M % M == 0 and M // N >= M:
    ans = M

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt


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

ans = 1
for i in range(1, int(sqrt(M))):
    if M % i == 0 and M / N >= i:
        ans = i

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
num=m//n
while num!=0:
    if m%num==0:print(num);break
    else:
        num //=2

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
num=m//n
while num!=0:
    if m%num==0:print(num);break
    else:
        num **=0.5
        num=int(num)

Submission status: Wrong Answer

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

if m % n == 0:
    print(m//n)
else:
    a = m // n
    print(m % a)

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 m//i < n:
            break
        else:
            ans = 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:
        if i >= M // N:
            ans = max(ans, M // i)
        if M // i >= M // N:
            ans = max(ans, i)

print(int(ans))

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
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
div = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_left(div,N)
print(div[ind])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
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
div = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_right(div,N)
print(div[ind-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = set()
for i in range(1, sqrtm):
    if M % i == 0:
        D.add(i)
        D.add(M // i)
ans = 0
for d in D:
    if d * N <= M:
        ans = d
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = []
for i in range(1, sqrtm):
    if M % i == 0:
        D.append(i)
ans = 0
for d in D:
    if d * N <= M:
        ans = d
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = []
for i in range(2, sqrtm):
    if M % i == 0:
        D.append(i)
ans = 0
for d in D:
    if d * N <= M:
        ans = d
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
for i in reversed(range(1, int(M**0.5)+1)):
    if M % i != 0:
        continue
    if N * i <= M:
        print(i)
        exit()

Submission status: Wrong Answer

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

for i in reversed(range(1, int(N**0.5)+1)):
    if M % i == 0:
        if N * i <= M:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


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

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

if is_prime(M):
    print(1)
    exit()

ans = 0
for i in range(1, M+1, N):
    d, m = divmod(M, i)
    if m == 0 and d >= N:
        ans = i
    if d < N:
        break

print(ans)

Submission status: Wrong Answer

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

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

for i in yakusuulst:
    Z=i*N
    if M-Z>=0:
        if (M-Z)%i==0:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split());[(print(i),exit())if(M%i==0and M//i>N)else 0 for i in range(M,0,-1)]

Submission status: Wrong Answer

Solution code:
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max:
        ans=m//i
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max*n:
        ans=m//i
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
# AGC112 D - Partition
from math import floor
from fractions import gcd
def divisor(n): 
    """
    xの約数を列挙する。

    Parameters
    ----------
    x: int
        約数を求めたい自然数

    Returns
    -------
    retlist：list
        約数のリスト

    """
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

n_max=floor(m/n)
div_m=divisor(m)
ans=0
for i in range(1,int(m**0.5)+1):
    if i%n==0 and i//n in div_m:
        q=m//i
        r=m%i
        ans=gcd(q,q+r)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
# AGC112 D - Partition
from math import floor
from fractions import gcd
n,m=map(int,input().split())
if m%n==0:
    print(m//n)
    exit()

n_max=floor(m/n)
ans=0
for i in range(n_max,0,-1):
    if i%n==0:
        q=m//i
        r=m%i
        ans=gcd(q,q+r)
        print(ans)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=M//N
b=min(a,N)
while (M&b)!=0:
  b-=1
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
n = M // N
import math
m = math.ceil(M**0.5)
for i in range(min(n,m)):
    x = n - i
    if M % x == 0:
        print(x)
        quit()

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

n, m = map(int, sys.stdin.readline().split())

def main():
    res = [i for i in range(1, floor(sqrt(m))+1) if not m % i]
    ans = res[bi_r(res, m // n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

n, m = map(int, sys.stdin.readline().split())

def factorize(n):
    res = [1]
    for i in range(2, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
    return res

def main():
    res = factorize(m)
    ans = res[bi_r(res, m // n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

n, m = map(int, sys.stdin.readline().split())

def factorize(n):
    res = [1]
    for i in range(2, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
    if n >= 2:
        res.append(n)
    return res

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう →約数ならば

from math import sqrt

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

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

s = min(ans, int(sqrt(M)) + 1)
for a in range(s, 0, -1):
    if M % a == 0:
        print(a)
        exit()

# print(1)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう →約数ならば

from math import sqrt

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

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

s = min(ans, int(sqrt(M) + 1))
for a in range(s, 0, -1):
    if M % a == 0:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう

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

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

from math import sqrt
for a in range(int(sqrt(ans)) + 1, 0, -1):
    if M % a == 0:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
k = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        k1 = 1
        k2 = 1
        if b>=N-1:
            k1 = a
        if a>=N-1:
            k2 = b
        k = max(k,k1,k2)
print(k)

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:
        a = i
        b = M//i
        if M//i>=N-1:
            k = a
print(k)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    S = M
    q = 0
    while S > M // N:
      S = M // X[q]
      q += 1
      if q == len(X):
        break
    if q == len(X):
      S = max(X)
print(S)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    for i in range(len(X)):
      if M % X[i] == 0:
        if M // X[i] >= N:
          S = X[i]
        else:
          break
print(S)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    for i in range(len(X)):
      if M % X[i] == 0 and X[i] >= N:
        S = M // X[i]
        break
print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
x = 2
res = 0
while x * x <= M:
  if M % x == 0:
    if M // x >= N: res = max(res, x)
    y = M // x
    if M // y >= N: res = max(res, y)
  x += 1
if res == 0: print(1)
else: print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
x = 2
res = 0
while x * x <= M:
  if M % x == 0:
    if M // x >= N: res = max(res, x)
    y = M // x
    if M // y >= N: res = max(res, x)
  x += 1
if res == 0: print(1)
else: print(res)

Submission status: Wrong Answer

Solution code:
import math
import sys

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

def solve(x):
    return M % x == 0 and M / x >= N

# The method to fix border
def fixBorder(m):
    if not solve(m) and solve(m+1):
        return m+1
    elif not solve(m) and solve(m-1):
        return m-1
    else:
        return m


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

l = 1
r = 10**10
m = math.ceil((l+r)/2)

while l <= r:
    m = math.ceil((l+r)/2)
    # print(l, r, m)

    if solve(m):
        # print('too small!')
        l = m+1
    else:
        # print('too big!')
        r = m-1

# print(m)
print(fixBorder(m))

'''
72 135
should be 1
'''

Submission status: Wrong Answer

Solution code:
import math
import sys

def solve(x):
    return M % x == 0

# The method to fix border
def fixBorder(m):
    if not solve(m) and solve(m+1):
        return m+1
    elif not solve(m) and solve(m-1):
        return m-1
    else:
        return m

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

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

l = 1
r = 10**10
m = math.ceil((l+r)/2)

while l <= r:
    m = math.ceil((l+r)/2)
    # print(l, r, m)

    if solve(m):
        # print('too small!')
        l = m+1
    else:
        # print('too big!')
        r = m-1

# print(m)
print(fixBorder(m))

Submission status: Wrong Answer

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

import math
sq=int(math.sqrt(m))//1

#計算量減らすために、予め約数のリスト用意。
yaku=[]
for i in range(1,sq):
  if m%i==0:
    yaku.append(i)
    yaku.append(m//i)
yaku.sort(reverse=True)

for i in yaku:
  if n*i<=m:
    print(i)
    exit()

Submission status: Wrong Answer

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

import math
sq=int(math.sqrt(m))//1

for i in range(sq):
  if m%(sq-i)==0:
    if (sq-i)*n<=m:
      print((sq-i))
      exit()

Submission status: Wrong Answer

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

import math
sq=int(math.sqrt(10**9))//1

for i in range(sq):
  if m%(sq-i)==0:
    if (sq-i)*n<=m:
      print((sq-i))
      exit()