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: Runtime Error

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

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

Submission status: Runtime Error

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

    divisors.sort(reverse=True)
    return divisors

lis=make_divisors(m)

for mm in lis:
    if mm<=i:
        ans=mm
        break

print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nm <= mi:
    ps.append(nw)

print(max(ps))

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())
ps = []
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nm <= mi:
    ps.append(nw)

print(max(ps))

Submission status: Runtime Error

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

for _ in range(m)
    if m%n==0:
        print(m//n)
        exit()
    n+=1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import collections
from math import ceil
ma = lambda : map(int,input().split())
ni = lambda : int(input())

n,m = ma()
gcd = 1
for d in range(m//n-2*n,m//n+1):
    q,r = divmod(m,d)
    if r == 0 and q>=n:gcd = d
print(gcd)

Submission status: Runtime Error

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

base=M//N
answer=[0]*N
j=0

for i in range(base,base//2+1,-1):
    if M%i==0:
        answer[j]=i
        break
    elif M%(base-i+1)==0:
        answer[j]=base-i+1
        j+=1
print(max(answer))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
i = 1
lis = []
while M//i>=N and i<M**0.5:
  if M % i == 0:
    lis.append(i)
  i += 1
print(lis[-1])

Submission status: Runtime Error

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

from math import ceil

def main():
  n, m = map(int, input().split())
  for i in list(range(1, ceil(m/n)+1))[::-1]:
    if m%i == 0 and m//i >= n:
      print(i)
      return

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
ind=bisect.bisect_left(enum,m//n)
if(enum[ind]==m//n):
    print(enum[ind])
elif(ind==0):
    print(enum[ind])
else:
    print(enum[ind-1])

Submission status: Runtime Error

Solution code:
import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
ind=bisect.bisect_left(enum,m//n)
if(enum[ind]==m//n):
    print(enum[ind])
else:
    print(enum[ind-1])

Submission status: Runtime Error

Solution code:
N,M=map(int,input())
t=M//N
#Mを因数分解する必要など無いか…？
#print(t)
for p in reversed(range(2,t+1)):
    if M%p==0:
        print(p)
        break

Submission status: Runtime Error

Solution code:
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [2, m//2]
else:
    divisor = []
for i in range(3, int(math.sqrt(m))+1):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)

Submission status: Runtime Error

Solution code:
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [2, m//2]
else:
    divisor = []
for i in range(3, int(math.sqrt(m))+1, 2):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
ans=int(0)
for i in range(int(math.sqrt(m))):
    if m<n*i:
        break
    if m%i==0:
        ans=i
print(ans)

Submission status: Runtime Error

Solution code:
#112_D
N,M=map(int,input().split())
#M//N以下のMの約数の最大
divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divitors.append(i)
        if i!=(M//i):
            divitors.append(M//i)
Ans=1
for x in divitors:
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)

Submission status: Runtime Error

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

fact = []
for i in range(1, int(m**0.5)):
    if m%i==0:
        fact.append(i)
        fact.append(m//i)
fact.sort()

for i in fact:
    if n*i<=m: ans = i
print(ans)

Submission status: Runtime Error

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

fact = []
for i in range(2, int(m**0.5)):
    if m%i==0:
        fact.append(i)
        fact.append(m//i)
fact.sort()

for i in fact:
    if n*i<=m: ans = i
print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
divisors = sorted(sum(([*{n, M // n}] for n in range(1, int(M ** 0.5) + 1) if not M % n), []), reverse=True)

for d in divisors:
    if M // d >= N:
        print(d)
        break

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
N,M=map(int,input().split())
A=[]
for i in range(1,int(math.sqrt(M))):
    if M%i==0:
        if M//i>=N:
            A.append(i)
            if i>=N and M//i>i:
                A.append(M//i)

A.sort()

print(A[-1])

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
N,M=map(int,input().split())

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

Submission status: Runtime Error

Solution code:
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort()
    return a

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

f = factorization(M)
f = np.array(f)
print(np.max(f[f<=M/N]))

Submission status: Runtime Error

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

n,m=map(int,input().split())
l=divisore(m)
for i in l:
  if m/n>=i:
  print(i)
  exit()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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)
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Submission status: Runtime Error

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])

for i in reversed(range(1,M)):
  f = M/i
  if(f.is_integer() == True):
    #print(i)
    if(N*i<=M):
      ans = i
      break


print(ans)

Submission status: Runtime Error

Solution code:
import math

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

d=[]
i=1
while math.sqrt(M)>=i:
    if M%i==0:
        d.append(i)
        if i**2!=M:
            d.append(M//i)
    i=i+1
d.sort()#Mの約数列

m=0
i=0
while  M//N>=d[i]:
    if M%d[i]==0:
        m=d[i]
    i=i+1
print(m)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=divisor(m)
d.sort(reverse=1)
for i in d:
  if m//i>=n:print(i):exit()

Submission status: Runtime Error

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,m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

Submission status: Runtime Error

Solution code:
import math
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
      if search_list[0] > math.sqrt(number):
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list


n,m=map(int,input().split())
A=get_primenumber(m//n)
ans=2
for i in A:
    if m%i==0:ans=i
print(ans if m%n!=0 else m//n)

Submission status: Runtime Error

Solution code:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
n = M // N
def f(n):
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
    return True
if f(M):
    return(1)
    quit()
for i in range(n):
    x = n - i
    if M % x == 0:
        print(x)
        quit()

Submission status: Runtime Error

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

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

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


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

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

Submission status: Runtime Error

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, sqrt(M) + 1)
for a in range(s, 0, -1):
    if M % a == 0:
        print(a)
        exit()

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d.extend(i,M//i)
d=list(set(d)).sort()
for x in d:
  if x>=N:
    print(M//x)
    break

Submission status: Runtime Error

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

N,M = map(int,input().split())
g=max(M//N,M**0.5)#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()

Submission status: Runtime Error

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()

Submission status: Runtime Error

Solution code:
vimport sys


def main():
    N, M = map(int, input().split())
    s = M // N  # 答えはs以下
    m = M % N

    for i in range(s, 0, -1):
        if m % s == 0:
            print(s)
            sys.exit()
        else:
            s -= 1
            m += N


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

k = M // N　+ 1
ans = 1
for i in reversed(range(1, k+1)):
    if ans > i:
        break
    tmp =  max(M - (N-1)*i,1)
    ans = max(ans, fractions.gcd(i, tmp))

print(ans)

Submission status: Runtime Error

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

k = M // N　+ 1
ans = 1
for i in reversed(range(1, k+1)):
    if ans > i:
        break
    ans = max(ans, max(fractions.gcd(i, M - (N-1)*i), 1))

print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import fractions as ft
n=int(input())
a=list(map(int,input().split()))
my_max=max(a)
b=[0]*(my_max+1)
def md(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            b[i]+=1
            if i != n // i:
                b[n//i]+=1

def sosuu(n):
    for p in range(2, n):
        if n % p == 0:
            #print(str(n) + ' is composite.')
            return False
    return True

ans=0
for i in range(n):
    md(a[i])

m=n-1
cnt=0
for i in range(my_max,0,-1):
    if b[i]==m:
        cnt=i
        break
    if cnt==0:
        if b[i]==n:
            cnt=i
            
print(cnt)

Submission status: Runtime Error

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

    start = min(m//n,math.sqrt(m))

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

main()

Submission status: Runtime Error

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

a = int(m /n)

for i in range(min(a,m/2),0,-1):
  if m % i == 0:
    print(i)
    break

Submission status: Runtime Error

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

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


# そもそも素数だとだめなので、素数判定
pn = 2
is_prime = True
while pn*pn <= M:
    if M % pn == 0:
        #その数字以外のある数字で割り切れるので素数ではない
        is_prime = False
        break
    pn += 1


if is_prime == False:
    ans = 1
    for i in reversed(range(1, (M**0.5)+1)):
        # 最大公約数がiとする
        rest = M - (i * N)
        if (i+rest) % i == 0:
            ans = i
            break
else:
    if N == 1:
        ans = M
    else:
        ans = 1

print(ans)

Submission status: Runtime Error

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

    # divisors.sort()
    return divisors

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>N]
print(M//min(arr))

Submission status: Runtime Error

Solution code:
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
N,M = map(int,input().split())
if N==1:
    x = M
elif P[M]==1:
    x = 1
else:
    b = M//N
    for i in range(b,0,-1):
        if M%i==0:
            x = i
            break
print(x)

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
mm = m // n
res = []
for k in range(1, int(math.sqrt(m))):
    if m % k == 0:
        if k > mm:
            break
        if m // k <= mm:
            k = m // k
        res.append(k)
print(max(res))

Submission status: Runtime Error

Solution code:
import collections
import itertools
import math


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = map(int, input().split())
m2 = math.ceil(math.sqrt(m))
sieve = eratosthenes(m2)
counter = collections.Counter()

mm = m
for k in range(2, m2):
    if sieve[k] and m % k == 0:
        while mm % k == 0:
            mm //= k
            counter[k] += 1
if mm > 1:
    counter[mm] += 1

es = [range(k + 1) for k in counter.values()]
res = 1
for ks in itertools.product(*es):
    x = 1
    for p, k in zip(counter.keys(), ks):
        x *= p**k
    if x <= m // n:
        res = max(res, x)
print(res)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())  # 項数N, Aの和M

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

# Mの約数を列挙する
primes = []
ans = 1


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

# 約数が全て手に入った
for d in primes:
    if M >= N * d:
        ans = d

print(d)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1

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

for i in range(1000000):
    if (M >= N * i) and (M % i == 0):
        ans = i

print(ans)

Submission status: Runtime Error

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    md = 1
    for i in range(1, (m // n + 1) ** 0.5 + 1):
        if m % i == 0:
            md = max(md, i)
    print(md)


if __name__ == '__main__':
    slove()

Submission status: Runtime Error

Solution code:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1];

            if (M % N == 0)
                Console.WriteLine(M / N);
            else
            {
                var div = M / N;
                var rem = M % N;
                Console.WriteLine(Gcd(div, rem));
            }
        }

        static int Gcd(int a, int b)
        {
            if (a < b) Gcd(b, a);
            if (b == 0) return a;
            return Gcd(b, (a % b));
        }
    }
}

Submission status: Runtime Error

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

limit=int(m**(1/2))+1

divisors=[]
for d in range(limit):
    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: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in rreversed(range(1, x+1)):
        if M%i == 0:
            print(i)
            break

Submission status: Runtime Error

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

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

print(count)

Submission status: Runtime Error

Solution code:


# N < 10^5
# N <= M <= 10^9
from math import sqrt, ceil
def solve(N, M):
    p = 1
    for n in range(1, ceil(sqrt(M))+1):
        q, r = divmod(M, n)
        if r != 0:
            continue
        if q < N:
            break
        p = n
    return p

#print(solve(3, 14))
#print(solve(10, 123))
#print(solve(100000, 1000000000))
N, M = map(int, input().splt())
print(solve(N, M))

Submission status: Runtime Error

Solution code:


# N < 10^5
# N <= M <= 10^9
from math import sqrt, ceil
def solve(N, M):
    p = 1
    for n in range(1, ceil(sqrt(M))+1):
        q, r = divmod(M, n)
        if r != 0:
            continue
        if N <= q:
            break
        p = n
    return p

#print(solve(3, 14))
#print(solve(10, 123))
#print(solve(100000, 1000000000))
N, M = map(int, input().splt())
print(solve(N, M))

Submission status: Runtime Error

Solution code:
# 求める出力は，mの約数iのうち n*i <= m を満たす最大の整数n．

N, M = map(int, input().split())
fracs = []
i = 2
m = M
# mの素因数分解を求める
while m > 1 and M**0.5:
  while m % i == 0:
    m //= i
    if len(fracs)==0:
      fracs.append([i, 1])
    elif fracs[-1][0] == i:
      fracs[-1][1] += 1
    else:
      fracs.append([i, 1])    
  i += 1

if m != 1:
  fracs.append(m, 1)

# 約数を全て列挙する
divisors = []
def search(i, p):
  for j in range(fracs[i][1]+1):
    if i != len(fracs)-1:
      new_p = p * fracs[i][0] ** j
      search(i+1, new_p)
    else:
      divisors.append(p * fracs[i][0] ** j)
search(0, 1)

print(sorted(list(filter(lambda x: x*N <= M, divisors)))[-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
def composite(n):
  sq = math.sqrt(n)
  lag = False
  if sq%1 == 0:
    flag = True
  sq = int(sq)
  ps_ = []
  for i in range(1,sq+2):
    if n % i == 0:
      ps_.append(i)
  ps = [n//p for p in ps_]
  ps.extend(reversed(ps_))
  if flag:
    ps.remove(sq)
  return ps

n, m = map(int, input.split())
comp = composite(m)
for i, c in enumerate(comp):
  if c < n:
    print(m // comp[i-1])

Submission status: Runtime Error

Solution code:
import math

n, m = list(map(int, input().split()))
k = 0
for i in range(1, int(math.sqrt(m) + 1)):
    if m % i == 0 and m/k >= n:
        k = i
print(k)

Submission status: Runtime Error

Solution code:
import math

n, m = list(map(int, input().split()))
k = 0
for i in range(1, int(math.sqrt(m) + 1):
    if m % i == 0:
        k = i
print(k)

Submission status: Runtime Error

Solution code:
# 2019/08/01

from fractions import gcd

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

def divisors(n,m):
    div=[]
    end=min(m//n,int(pow(m,0.5)))
    for i in range(2,end+1):
        if m%i==0:
            div.append(i)
    return div

res=divisors(n,m)
print(res[-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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))

i = 0
while i<=len(div) and M//div[i]>=N:
    ans = div[i]
    i+=1
    
print(ans)

Submission status: Runtime Error

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))
i = 0
while M//div[i]>=N:
    ans = div[i]
    i+=1
    
print(ans)

Submission status: Runtime Error

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))
while M//div[i]>=N:
    ans = div[i]
    i+=1
    
print(ans)

Submission status: Runtime Error

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)
    	else:
            mx = max(mx, M//i)
print(mx)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in make_divisors(M):
    if i < M // N:
        ans = i 
print(ans)

Submission status: Runtime Error

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: Runtime Error

Solution code:
n,m=map(int,input().split())
ans=1
for i in range(1,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: Runtime Error

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 = []
    for i in range(1, int(ceil(sqrt(M)))):
        if M % i == 0:
            ds.append(i)
            ds.append(M // i)
    ds.sort()
  
    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: Runtime Error

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

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

gcd = 0
for i in range(len(F)):
    if F[i] * N > M:
        break

    gcd = F[i]

print(gcd)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)):
    if M%i == 0:
        if i <= N:
            a.append(i)
        else:
            a.append(int(M/i))
print(max(a))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2),m//n)+1):
    if m%i==0:
      l.append(i)
      if m//i!=i and m//i<=m//n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))