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: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
import numpy as np

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def divisor_sub(p, q):
    a = []
    for i in xrange(0, q + 1):
        a.append(p ** i)
    return a

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()
##    div_list = divisor(M)
##    div_list.sort(reverse = True)
##
##    for num in div_list:
##        if M % num == 0 and M/num >= N:
##            print num
##            exit()

    max_p = 0
    for p in range(int(math.sqrt(M) + 0.5) , 0, -1):

        if(M % p == 0):
            q = M/p
            if q >= N:
                max_p = max(p, max_p)
            if p >= N:
                max_p = max(q, max_p)
    print max_p

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
 
N,M = map(int,input().split())
 
ans = 1
for i in range(1,int(math.sqrt(M))+1+1):
  if M % i != 0:#約数ではないとき
    continue
  B = int(M / i)#intとらないと，N = 1 , M = 100 のとき　ans = 100.0になってエラー？
  
  if (i * N <= M):
    ans = max(ans,i)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)

Submission status: Accepted

Solution code:
import time
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    mrFlg = 0
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    while i**2 <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        if i == 2:
            i = 3
        else:
            i += 2
        if i == 101 and n >= (2**20):
            def findFactorRho(N): # Primeでないことを確認したものを引数とする。
                def gcd(a, b):
                    if b == 0:
                        return a
                    else:
                        return gcd(b, a % b)
                def f(x, c):
                    return ((x ** 2) + c) % N
                semi = [N]
                for c in range(1, 11):
                    x=2
                    y=2
                    d=1
                    while d == 1:
                        x = f(x, c)
                        y = f(f(y, c), c)
                        d = gcd(abs(x-y), N)
                    if d != N:
                        if isPrimeMR(d):
                            return d
                        elif isPrimeMR(N//d):
                            return N//d
                        else:
                            semi.append(d)

                semi = list(set(semi))
                print (semi)
                s = min(semi)
                for i in [2,3,5,7]:
                    while True:
                        t = int(s**(1/i)+0.5)
                        if t**i == s:
                            s = t
                            if isPrimeMR(s):
                                return s
                        else:
                            break

                i = 3
                while True:
                    if s % i == 0:
                        return i
                    i += 2
                    
            while True:
                if isPrimeMR(n):
                    break
                else:
                    mrFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                        ret[j] = k
                if n == 1:
                    break
        
    if n > 1:
        ret[n] = 1
    if mrFlg > 0:
        def dict_sort(X):
            Y={}
            for x in sorted(X.keys()):
                Y[x] = X[x]
            return Y
        ret = dict_sort(ret)
    return ret

def isPrime(N):
    if N <= 1:
        return False
    return sum(primeFactor(N).values()) == 1

def isPrimeMR(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for a in [2, 3, 5, 7, 11, 13, 17, 19]:
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True        

def findPrime(N):
    if N < 0:
        return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

N, M = map(int, input().split(" "))
 
for i in divisors(M):
    if i >= N:
        print (M//i)
        break

Submission status: Accepted

Solution code:
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    d = 2
    sq = int(n ** (1/2))
    while i <= sq:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        if k > 0:
            sq = int(n**(1/2))
        if i == 2:
            i = 3
        elif i == 3:
            i = 5
        elif d == 2:
            i += 2
            d = 4
        else:
            i += 4
            d = 2
        
    if n > 1:
        ret[n] = 1
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

N, M = map(int, input().split(" "))
 
for i in divisors(M):
    if i >= N:
        print (M//i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

M = set()
for i in range(1, ceil(sqrt(m))+1):
    if m % i == 0:
        M.add(i)
        M.add(m//i)
M = sorted(list(M), reverse=True)
#print(M)
for i in M:
    if i <= m // n:
        print(i)
        break

Submission status: Accepted

Solution code:
import math, collections, itertools, functools, operator
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1 or not factors:
            factors.append(cur)
        return factors
    @staticmethod
    # Returns a list of factors
    def factors(n):
        pf = PrimeUtils.pfd(n)
        pfc = collections.Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]

N, M = map(int, input().split())
for factor in sorted(PrimeUtils.factors(M)):
    if N <= factor:
        print(M // factor)
        break
else:
    print(1)

Submission status: Accepted

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

MAX_RES = int(math.sqrt(M))
res = 1
for i in range(1, MAX_RES + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Accepted

Solution code:
import sys
import math
Input = sys.stdin.readline
 
N, M = map(int, Input().split())
D = []
 
for i in range(int(math.sqrt(M)), 0, -1):
    if M % i == 0:
      D.append(i)
      D.append(M // i)

D.sort(reverse=True)
for d in D:
    if M >= N*d:
        print(d)
        break

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
if N > 1:
  devides[1] = 1
  for prime in primes:
    _devides = [d for d in devides]
    for i in range(N):
      if devides[i]:
        if i * prime < N:
          _devides[i * prime] = 1
        else:
          ans = max(M // i // prime, ans)
    devides = _devides
else:
  ans = M
print(ans)

Submission status: Accepted

Solution code:
import math

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

x=int(math.sqrt(m))

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

Submission status: Accepted

Solution code:
import math

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

x=int(math.sqrt(m))

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

Submission status: Accepted

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

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

yakusu.sort(reverse=True)

for i in yakusu:
    if i <= M/N:
        print(i)
        break

Submission status: Accepted

Solution code:
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []

def ans():
    ans = 1
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
                m.append(T//i)
    for p in m:
        if p <= T // N:
            ans = max(ans,p)
    print (ans)
    
if T % N == 0:
    print (int(T / N))
else:
    ans()

Submission status: Accepted

Solution code:
def d_partition(N, M):
    if N == 1:
        return M  # a_1 = M とする他なく、これが最大公約数

    def divisor_list(n):
        # n の正の約数のリスト
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.extend([k, n // k])
        ret.sort()
        return ret

    divisor_m = divisor_list(M)
    ans = -1
    for d in divisor_m:
        if d <= M // N:
            ans = d
        else:
            break
    return ans

N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

# N = 100000
# M = 1000000000

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

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []
for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans.append(i)
print(max(ans))

# ans2 = 1
# for i in L[::-1]:
#     if (M - (N * i)) % i == 0:
#     # if M % i == 0:
#         ans2 = i
#         break
# print(ans2)

Submission status: Accepted

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

lstDiv = []
k = 1
while k * k <= m:
    div, r = divmod(m, k)
    if r == 0:
        lstDiv.append(k)
        lstDiv.append(div)
    k += 1

lstDiv = sorted(lstDiv, reverse=True)

for div in lstDiv:
    if div * n <= m:
        print(div)
        break

Submission status: Accepted

Solution code:
import math
n, m = map(int, input().split())
X=1
for i in range(1,32000):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

# N = 100000
# M = 1000000000

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

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []

for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans.append(i)

print(max(ans))

Submission status: Accepted

Solution code:
import math

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

# N = 100000
# M = 1000000000

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

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []

for i in L[::-1]:
    # if (M - (N * i)) % i == 0:
    if M % i == 0:
        ans.append(i)

print(max(ans))

Submission status: Accepted

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

mm.sort(key=lambda x:-x)
for i in mm:
    if i<=m/n:
        print(i)
        break

Submission status: Accepted

Solution code:
from math import sqrt, floor
 
N, M = map(int,input().split())
 
rootM = floor(sqrt(M))
l = []
for i in range(1, rootM +1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)
        
ans = 1
for li in l:
    ans = max(ans, li) if li <= M // N else ans
print(ans)

Submission status: Accepted

Solution code:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

As = []
k = 1
while k * k <= M:
    if M % k == 0:
        As.append(k)
        As.append(M // k)
    k += 1

As = sorted(As, reverse=True)

for ans in As:
    if M // ans >= N:
        print(ans)
        break

Submission status: Accepted

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

i = 1
yakusuu = []
while i*i <= m:
    if m%i==0:
        yakusuu.append(i)
        if i*i != m:
            yakusuu.append(m//i)
        
    i += 1

yakusuu.sort()

for i in yakusuu:
    if n <= i:
        print(m//i)
        break

Submission status: Accepted

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

num = []
i = 1
while i * i <= m:
    if m % i == 0:
        num.append(i)
        if m // i != i:
            num.append(m//i)
    i += 1

ans = 0
for i in num:
    if i <= m // n:
        ans = max(ans, i)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt, ceil
def inpl(): return list(map(int, input().split()))

N, M = inpl()
ans = 1
for i in range(1, ceil(sqrt(M))+1):
    if M%i != 0:
        continue
    d = M // i
    if M >= N*i:
        ans = max(i, ans)
    if M >= N*d:
        ans = max(d, ans)

print(ans)

Submission status: Accepted

Solution code:
# coding : utf-8

import math

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

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

ans = 1
for l_ in l:
    if l_ <= M//N:
        ans = max(ans,l_)

print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
import math
s = math.sqrt(M)
sq = math.floor(s)
l = []
for i in range(1,sq+1):
    if M%i == 0:
        l.append(i)
        l.append(M//i)
ans = 1
for r in l:
    n = M//r
    if n >= N:
        ans = max(ans,r)
print(ans)

Submission status: Accepted

Solution code:
# coding : utf-8

import math

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

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

ans = 1
for l_ in l:
    if l_*N <= M:
        ans = max(ans,l_)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)
		s.append(m//(i+1))




for i in s:
	if m%(i)==0 and m//(i)>n-1:
		x=max(x,i)
print(x)

Submission status: Accepted

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

yakusuu = []
for i in range(1, int((M + 1)**(1/2)+1)):
    if M % i == 0:
        yakusuu.append(i)
        yakusuu.append(int(M/i))
yakusuu.sort()
yakusuu.reverse()


for i in yakusuu:
    if M / i >= N:
        print(i)
        break

Submission status: Accepted

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

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d+1,0,-1):
    	if M%i == 0:
    		print(i)
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Accepted

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

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div
factors = divisors(M)
k = M//N
L = [x for x in factors if x <= k]
print(max(L))

Submission status: Accepted

Solution code:
import math
N,M=map(int,input().split())
K=int(math.sqrt(M))+1
D=set()
for i in range(1,K+10):
    if M%i==0:
        D.add(M//i)
        D.add(i)
X=[]
for d in D:
    if M//d>=N:
        X.append(d)
print(max(X))

Submission status: Accepted

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

a = []
x = 1
while x * x <= M:
    if M % x == 0:
        a.append(x)
        a.append(M/x)
    x += 1

res = 0
for i in a:
    if M / i >= N:
        res = max(res, i)
print(res)

Submission status: Accepted

Solution code:
#coding:utf-8
import math
N, M = map(int, input().split())
yakusu = []
for i in range(1, min(int(M / N) + 1, int(math.sqrt(M)) + 1)):
    if M % i == 0:
        yakusu.append(i)
        if int(M / i) * N <= M:
            yakusu.append(int(M / i))
print(max(yakusu))

Submission status: Accepted

Solution code:
import math


def divisor(num):
    if num < 0:
        return [0,]
    elif num == 1:
        return [1,]
    else:
        divisor_list =[1,]
        for i in range(2, int(math.sqrt(num) + 1)):
            if num % i== 0:
                divisor_list.append(i)
        return divisor_list


N,M = map(int,input().split(' '))
P = M // N
divisor_list = divisor(M)

for i in reversed(range(len(divisor_list))):
    num = M // divisor_list[i]
    divisor_list.append(num)

for i in reversed(range(len(divisor_list))):
    if divisor_list[i] <= P:
        print(divisor_list[i])
        break

Submission status: Accepted

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
import numpy as np

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def divisor_sub(p, q):
    a = []
    for i in xrange(0, q + 1):
        a.append(p ** i)
    return a

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()
    div_list = divisor(M)
    div_list.sort(reverse = True)

    for num in div_list:
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solve():
    ans = 1
    for i in range(M//N+1, 0, -1):
        if M % i == 0:
            if (M // i) >= N:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Accepted

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / param:
        break
    ans = param
print(ans)

Submission status: Accepted

Solution code:
from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    try:
        b, e = fct.pop()  # base, exponent
    except:
        return []
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

M_divisors = divisorize(factorize(M))
threshold = M // N
max_possible_divisor = 1
for M_divisor in M_divisors:
    divisor = num(M_divisor)
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Submission status: Accepted

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Submission status: Accepted

Solution code:
import math

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

a = int(M/N)
q = int(math.sqrt(M))

m = 0
for i in range(1,q+1):
    if M % i == 0:
        if i <= a:
            m = max(m,i)
        b = int(M / i)
        if b <= a:
            m = max(m,b)

print(m)

Submission status: Accepted

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Submission status: Accepted

Solution code:
from math import sqrt

def factorization(n):
    l = set()
    for i in range(1, int(sqrt(n))+1):
        if not n % i:
            l.add(i)
            l.add(n//i)
    return l

N, M = map(int, input().split())
f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def x():
    for i in range(l+1)[::-1]:
        if m % i == 0:
            return i
print(x())

Submission status: Accepted

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

Submission status: Accepted

Solution code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    list = []
    for i in range(1,int(math.sqrt(M)+1)):
        if M%i == 0:
            list.append(i)
    for i in range(len(list)):
        list.append(int(M/list[i]))
    print(max([i for i in list if i <= M // N]))

Submission status: Accepted

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

ds = [x for x in range(1, int(m**.5)+1) if m%x==0]
ds = ds + [m//x for x in ds]
ds = [x for x in ds if x<=m//n]
print(max(ds))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
from math import sqrt,floor
k=1
divisor = []
sq = floor(sqrt(m))+2
while k < sq:
    if m%k==0:
        divisor += [k]
    k+=1

for v in divisor:
    if v >= n:
        print(m//v)
        exit()
divisor.reverse()
for v in divisor:
    if v <= m//n:
        print(v)
        exit()

Submission status: Accepted

Solution code:
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))+1):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

Submission status: Accepted

Solution code:
import math


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

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

print(ans)

Submission status: Accepted

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

if N == 1:
    print(M)
else:
    ans = 1
    for p in range(2, int(M**0.5) + 1):
        if M % p == 0 and p <= M // N:
            q = M // p # M = p*q
            ans = max(p, ans)
            if q <= M // N:
                ans = max(q, ans)
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1,ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
            l.append(n//i)
    return l
N, M = map(int, input().split())

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

f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split(" ")))
def solv(N, M):
    d = M//N
    for i in range(d+1)[::-1]:
        if M%i == 0:
            return i
print(solv(N, M))

Submission status: Accepted

Solution code:
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break