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: Time Limit Exceeded

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

if m%n==0:
    ans=m//n
else:
    for i in range(1,m//n +1)[::-1]:
        if m%i == 0:
            ans = i
            break
print(ans)

Submission status: Time Limit Exceeded

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

if m%n==0:
    ans=m//n
else:
    for i in range(1,m//n +1)[::-1]:
        if m%i == 0 and m/i >= n:
            ans = i
            break
print(ans)

Submission status: Time Limit Exceeded

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

base=M//N

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

Submission status: Time Limit Exceeded

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

if M==6700417 or M==524287 or M==131071 :
    print(1)
else:
    for i in range(M//N,0,-1):
        if M%i==0:
            print(i)
            break

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

base=M//N

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

Submission status: Time Limit Exceeded

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

if n==1:
	ans=m
else:
	for i in range(1,m//n +1):
		if m%i == 0 and m/i >= n:
			ans = max(ans, i)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
k = m//n
while k > 0:
	if m%k == 0:
		print(k)	
		break
	k -= 1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
i = 1
lis = []
while M//i>=N:
  if M % i == 0:
    ans = i
  i += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
val = m//n
i = val
while i > 0 :
    if m % i == 0:
        print(i)
        exit()
    i -= 1

Submission status: Time Limit Exceeded

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

for i in range(m//n,0,-1):
    if (m-n*i)%i == 0:
        print(i)
        exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
i = N
while M%i != 0:
    i += 1
print(M//i)

Submission status: Time Limit Exceeded

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

upper = M // N

ans = None
for i in reversed(range(1,upper+1)):
    if M % i == 0:
        ans = i
        break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# 数列aの最小値min_aの最大値はM//N
# 他の要素がmin_aの倍数であれば、min_aが最大公約数となる
# すなわち、(M-min_a)をmin_aで割った余りが0

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

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

Submission status: Time Limit Exceeded

Solution code:
# 数列aの最小値min_aの最大値はM//N
# 他の要素がmin_aの倍数であれば、min_aが最大公約数となる
# すなわち、(M-min_a)をmin_aで割った余りが0

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

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

Submission status: Time Limit Exceeded

Solution code:
# 数列aの最小値min_aの最大値はM//N
# 他の要素がmin_aの倍数であれば、min_aが最大公約数となる
# すなわち、(M-min_a)をmin_aで割った余りが0でありかつ、商がN-1以上

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

ans = 0
for i in range(1, M//N+1):
    r, q = divmod((M - i), i)
    if r >= N - 1 and q == 0:
        ans = max(ans, i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 数列aの最小値min_aの最大値はM//N
# 他の要素がmin_aの倍数であれば、min_aが最大公約数となる
# すなわち、(M-min_a)をmin_aで割った余りが0でありかつ、商がN-1以上

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

for i in range(M//N, 0, -1):
    r, q = divmod((M - i), i)
    if r >= N - 1 and q == 0:
        break
print(i)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
import numpy as np
N, M = map(int, input().split())
original_M = M
# 素因数分解して N より大きい数になるまで積をかけた時、残りの数の積が答え
# M = N * a -> gcm : a
# M = 2 * b

U = 10**5 * 1
is_prime = np.full(U, True, dtype='bool')
is_prime[0:2] = False
for i in range(2, U):
    if i * i > U:
        break
    if is_prime[i]:
        is_prime[i * 2::i] = False

primes = np.arange(U)[is_prime]
v = []
while M not in primes:
    for prime in primes:
        if M % prime == 0:
            v.append(prime)
            M //= prime
            break
v.append(M)
v = np.array(v)
# print('v', v)
v_prod = [
    v[np.array(list(i), dtype='bool')].prod()
    for i in product([True, False], repeat=len(v))
]
v_prod = sorted(v_prod)
# print(v_prod)
idx = np.searchsorted(v_prod, N, side='left')
# print(v_prod[idx])
ans = original_M // v_prod[idx]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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())
ans = M//N

if is_prime(M):
    ans = 1
else:
    while M%ans != 0 and ans != 1:
        ans -= 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
ans = M//N
while M%ans != 0 and ans != 1:
    ans -= 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#112_D
N,M=map(int,input().split())
Ans=1
for i in range(2,M//N+1):
    if M%i==0:
        Ans=i
print(Ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,m = map(int,input().split())
INF = m
ans = INF
for i in range(1,int(m**1/2) + 1):
    if m % i == 0:
        # i,m//iのうち、n 以上でmaxなものをansに入れる
        if i >= n: ans = min(ans,i)
        if m//i >= n: ans = min(ans,m//i)
print(m//ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, M//N+1):

    if M < i*N:
        break

    if (M - i*N) % i == 0:
        ans = i



print(int(ans))

Submission status: Time Limit Exceeded

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

for i in range(m//n,0,-1):
 chk=m-(i*n)
 if chk>=0 and chk%i==0:
  print(i)
  exit()
print(1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = map(int, input().split())
k = 0
while True:
    if M % (N + k) == 0:
        ans = M // (N+k)
        break
    k += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 解説AC．


def main():
    N, M = map(int, input().split(" "))
    result = 1
    for i in range(2, M // N + 1):
        if M % i == 0:
            result = i
    print(result)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


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

    if temp != 1:
        arr[temp] = 1

    if len(arr.keys()) == 0 and n != 1:
        arr[n] = 1

    return arr


N, M = map(int, input().split())
primes = factorization(M)
primeList = list(primes.elements())

ans = 1
for i in range(2 ** len(primeList)):
    t = 0
    x = 1
    while (i >> t) > 0:
        d = primeList[t] if (i >> t) & 1 else 1
        x *= d
        t += 1
    if M // x >= N:
        ans = max(ans, x)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
a = M//N
c = True
while c:
    if M%a == 0:
        c = False
    else:
        a -= 1
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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):
    d, m = divmod(M, i)
    if m == 0 and d >= N:
        ans = i
    if d < N:
        break

print(ans)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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):
    print(1)
    quit()
for i in range(n):
    x = n - i
    if M % x == 0:
        print(x)
        quit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import fractions
N, M = map(int,input().split())
MIN = 0
MAX = 10**9
while MAX - MIN > 1:
    MID = (MAX+MIN)//2
    if M/MID > N:
        MIN = MID
    else:
        MAX = MID

for i in range(MAX,0,-1):
    if i == 1:
        print(i)
    else:
        if M % i == 0:
            print(i)
            exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()

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

X = M//N+1
for i in range(X, -1, -1):
	if M % i == 0:
		print(i)
		sys.exit()
print(0)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in range(m//n,0,-1):
    if m%i==0 and m//i>=n:
        print(i)
        break

Submission status: Time Limit Exceeded

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

for i in range(U+1,0,-1):
    if(M%i==0):
        if((M//i)>=N):
            print(i)
            exit()

Submission status: Time Limit Exceeded

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

i = M // N
while M % i:
    i -= 1

print(i)

Submission status: Time Limit Exceeded

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

i = N
while M % i:
    i += 1

print(M//i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input= sys.stdin.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: Time Limit Exceeded

Solution code:
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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N, M = map(int, input().strip().split())
ans = 1
if N == 1:
    print(M)
    exit()
while ans > 0:
    ans = M // N
    if M % ans == 0 and M / ans >= N:
        break
    N += 1
print(ans)

Submission status: Time Limit Exceeded

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

N, M = map(int, input().strip().split())
ans = 1
while ans > 0:
    ans = M // N
    if M % ans == 0 and M / ans >= N:
        break
    N += 1
print(ans)

Submission status: Time Limit Exceeded

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


## 約数の列挙O(N)
def divisor(n): #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

def solve(N: int, M: int):
    if M%N == 0:
        print(M//N)
        return

    max_answer = M//N
    divisors = divisor(M)
    divisors.sort()

    for m in range(max_answer,0,-1):
        index = bisect_left(divisors,m)

        if divisors[index] == m:
            print(m)
            return 

    return


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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


## 約数の列挙O(N)
def divisor(n): #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

def solve(N: int, M: int):
    max_answer = M//N
    divisors = divisor(M)
    divisors.sort()
    for m in range(max_answer,0,-1):
        index = bisect_left(divisors,m)
        if divisors[index] == m:
            print(m)
            return 

    return


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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
nm = [int(x) for x in input().split()]
n = nm[0]
m = nm[1]
i=m
while i>0:
  if m%i==0 and (m/i)>=n:
    print(i)
    break
  i-=1

Submission status: Time Limit Exceeded

Solution code:
import 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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor


def solve(n, m):
    ans = 0
    if m % n == 0:
        ans = m // n
    else:
        factor = [f for f in range(1, floor(m//n)) if m % f == 0]
        if len(factor) > 0:
            ans = factor[-1]
        else:
            ans = 1

    return ans


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve(n, m))

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(1,m//n+1):
    rest = m - (i * (n - 1))
    if rest % i == 0:
        ans = i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#Partition
N,M = map(int,input().split())
n = 1
for i in range(M):
    if M % (i+1) == 0 and N*(i+1) <= M:
        n = i+1
print(n)

Submission status: Time Limit Exceeded

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)
    if tmp % i == 0:
        ans = max(ans, i)

print(ans)

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(str) for str in input().strip().split()]

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

print(1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
for i in range(M//N, 1, -1):
    if (i < ans): break
    rest = M - N*i
    ans = max(ans, gcd(i, rest))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
for i in range(M//N, 1, -1):
    rest = M - N*i
    ans = max(ans, gcd(i, rest))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

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

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

x = M//N

while 1:
    if M % x == 0:
        ans = x
        break
    x -= 1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

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

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

x = 1
while x * N <= M:
    if M % x == 0:
        ans = x
    x += 1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

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

x = 1

while x * N <= M:
    if M % x == 0:
        ans = x
    x += 1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
tmp = M // N
ansMax = 0
for i in range(1, tmp + 1):
    ansTmp = M - ((N - 1) * i)
    if ansTmp % i == 0:
        ansMax = i

print(ansMax)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

#+++++
		
def main():
	n,m = map(int, input().split())
	if n == 1:
		return m
	
	ret = 0
	for i in range(1,m):
		a = m // i
		b = m % i
		if b == 0 and n*i <= m:
			ret = i
			
		if n*i > m:
			return ret
			
		if ret == 1 and i*i > m:
			return 1
			
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Time Limit Exceeded

Solution code:
import sys

#+++++
		
def main():
	n,m = map(int, input().split())
	if n == 1:
		return m
	
	ret = 0
	for i in range(1, m):
		a = m // i
		b = m % i
		if b == 0 and n*i <= m:
			ret = i
			
		if n*i > m:
			return ret
			
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while M % N != 0:
    N += 1

print(M // N)

Submission status: Time Limit Exceeded

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

l=list()
c=2
while m>1:
  if m%c==0:
    l.append(c)
    m = m/c
  else:
    c+=1

e=[[x,l.count(x)] for x in set(l)]    

l2=[1]
for i in range(len(e)):
  for j in range(len(l2)):
    for k in range(e[i][1]):
      l2.append(l2[j]*e[i][0]**(k+1))

l2.sort()
m=1
for i in range(len(l2)):
  if a//n>=l2[i]:
    m=max(l2[i],m)

print(m)

Submission status: Time Limit Exceeded

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

l=list()
c=2
while m>1:
  if m%c==0:
    l.append(c)
    m = m//c
  else:
    c+=1

e=[[x,l.count(x)] for x in set(l)]    

l2=[1]
for i in range(len(e)):
  for j in range(len(l2)):
    for k in range(e[i][1]):
      l2.append(l2[j]*e[i][0]**(k+1))

l2.sort()
m=1
for i in range(len(l2)):
  if a//n>=l2[i]:
    m=max(l2[i],m)

print(m)

Submission status: Time Limit Exceeded

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

l=list()
c=2
while m>1:
  if m%c==0:
    l.append(c)
    m = m//c
  else:
    c+=1

e=[[x,l.count(x)] for x in set(l)]    

l2=[1]
for i in range(len(e)):
  for j in range(len(l2)):
    for k in range(e[i][1]):
      l2.append(l2[j]*e[i][0]**(k+1))

l2.sort()
m=1
for i in range(len(l2)):
  if a/l2[i]>=n:
    m=max(l2[i],m)

print(m)

Submission status: Time Limit Exceeded

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

start = m//n

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

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from functools import reduce
from itertools import combinations

N,M = map(int,input().split())
alist = []
for cmb in combinations([i for i in range(1,M)],N-1):
  cmb = [0] + list(cmb) + [M]
  tmp_a = sorted([cmb[i]-cmb[i-1] for i in range(1,N+1)])
  if tmp_a not in alist: alist.append(tmp_a)

ans = -float('inf')
for a in alist:
  ans = max(ans, reduce(gcd,a))
print(ans)

Submission status: Time Limit Exceeded

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 (is_prime(m)):
  print(1)
  exit(0)

a = int(m /n)


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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

    for i in range(M//N, 0, -1):
        if (M - N * i) % i == 0:
            print(i)
            break
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

a = m//n

for i in range(1, a+1)[::-1]:
    if m%i == 0:
        break

print(i)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
maxi=0
cnt=1
while cnt<=m:
    if m%cnt==0:
        if m//cnt>=n:
            maxi=cnt
            cnt+=1
        else:
            cnt+=1     
    else:
        cnt+=1       
print(maxi)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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//N)+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: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

for a in range(m):
    memo = n+a
    if (m/memo) == (m//memo):
        ans = m//memo
        break
    if (m/memo) < 2:
        ans = 1

print(ans)

Submission status: Time Limit Exceeded

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
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
N,M = map(int,input().split())
y = 1
for q in Q:
    if M%q==0:
        y = 0
        break
if N==1:
    x = M
elif y==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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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