Problem:


Score : 400 points

Problem Statement

You are given integers N and M.

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

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

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

Sample Input 1

3 14

Sample Output 1

2

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

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000



Sample input:
3 14


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math

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, math.ceil(M**0.5))):
        # 最大公約数が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: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

for i in range(M):
    if M%(i+1)==0:
        if (M-N*(i+1))>=0:
            ans=i+1
        else:
            print(ans)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

#素因数分解
def prime_factorize(n):
    if n == 1:
        return [1]
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n,m = inpl()
t = m//n
s = m % n
if len(prime_factorize(m)) == 1:
    print(1)
elif s == 0:
    print(t)
else:
    print(min(s,t))

Submission status: Wrong Answer

Solution code:
import math

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

q = int(math.sqrt(m))+1
li = [0 for i in range(10**6)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

q = int(math.sqrt(m))+1
li = [0 for i in range(10**5)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<m):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

q = int(math.sqrt(m))+10
li = [0 for i in range(10**5)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<m):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

q = int(math.sqrt(m))+10
li = [0 for i in range(10**5)]

for i in range(1,q):
    if (m/i) == (m//i):
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<m):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

q = int(math.sqrt(m))+10
li = [0 for i in range(10**5)]

for i in range(1,q):
    if (m/i) == (m//i):
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = i

print(ans)

Submission status: Wrong Answer

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


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

    ans = 0
    i = 1
    while i<=M//N and i**2<=M:
        if M%i==0:
            ans = i
        i += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
mm = m // n
for k in range(int(math.sqrt(m)) + 1, 0, -1):
    if m % k == 0:
        if k > mm:
            continue
        if m // k <= mm:
            k = m // k
        print(k)
        exit()

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
mm = m // n
for k in range(int(math.sqrt(m)) + 1, 0, -1):
    if m % k == 0:
        if k > mm and m // k > mm:
            continue
        if m // k <= mm:
            k = m // k
        print(k)
        exit()

Submission status: Wrong Answer

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())
tmp = []
for i in make_divisors(m):
    if m % i == 0 and m // i >= n:
        tmp.append(i)
print(tmp[-1])

Submission status: Wrong Answer

Solution code:
import sys
import math

N, M = map(int, input().split())
factors = [1]

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

for m in range(2, int(math.sqrt(M)) + 1):
    tmp = M
    while tmp % m == 0:
        factors.append(m)
        factors.append(tmp // m)
        tmp = tmp // m
factors.append(M)

for i in range(len(factors)):
    if factors[i] * N > M:
        ans = factors[i - 1]
        break
print(factors[i - 1])

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

# 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: Wrong Answer

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

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

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

ans = 1

for d in range(1, int(M**(1/2))+2):
    if M % d != 0:
        continue

    if M >= N * d:
        ans = max(ans, d)

print(ans)

Submission status: Wrong Answer

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

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

ans = 1

for d in range(1, int(M**(1/2))+2):
    if M % d != 0:
        continue

    if M >= N * d:
        ans = max(ans, d)

print(ans)

Submission status: Wrong Answer

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

ans = 1

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 1

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

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

Submission status: Wrong Answer

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

ans = 1

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

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

Submission status: Wrong Answer

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

ans = 1

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

for d in range(1, int(M**(1/2))+1):
    if M/N >= d and M % d == 0:
        ans = d
print(ans)

Submission status: Wrong Answer

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

ans = 1

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

if N == 1:
    print(M)

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:

def divisors(n):
    divisors_list = []

    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors_list.append((i,n//i))
    divisors_list.sort()
    return divisors_list

n, m = [ int(v) for v in input().split() ]
divisors_list = divisors(m)

ans = 1
for i in divisors_list:
    if i[1] >= n:
        ans = i[0]
print(ans)

Submission status: Wrong Answer

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(2, int(m ** 0.5) + 1):
        if m % i == 0:
            if n <= m // i:
                md = max(md, i)
            if n <= i:
                md = max(md, m // i)
    print(md)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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(2, int(m ** 0.5) + 1):
        if m % i == 0 and m // i >= n:
            md = max(md, i)
    print(md)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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, int((m // n + 1) ** 0.5) + 1):
        if m % i == 0:
            md = max(md, i)
    print(md)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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 + 2):
        if m % i == 0:
            md = max(md, i)
    print(md)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

# Mを i*j jがN以上なら i は a の 公約数である
# 最大値を記録しながら、公約数を全て探索
max_num = 1
for i in range(1, int(M**(1/2))+2):
    if M%i:
        continue
    j = M // i
    if j >= N:
        max_num = max(max_num, i)

print(max_num)

Submission status: Wrong Answer

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

# Mを i*j jがN以上なら i は a の 公約数である
# 最大値を記録しながら、公約数を全て探索
max_num = 1
for i in range(1, int(M**(1/2))+1):
    if M%i:
        continue
    j = M // i
    if j >= N:
        max_num = max(max_num, i)

print(max_num)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

limit = int(m**(1/2))
ans = 1
for d in range(1, limit+1):
    if m % d == 0 and m-d*n >= 0:
        ans = d
print(ans)

Submission status: Wrong Answer

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

limit = int(m**(1/2))
ans = 1
for d in range(1, limit+1):
    if m % d == 0 and m-d*n > 0:
        ans = d
print(ans)

Submission status: Wrong Answer

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

limit = int(m**(1/2))+1
ans = 0
for d in range(1, limit):
    if m % d == 0 and m-d*n > 0:
        ans = d
print(ans)

Submission status: Wrong Answer

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

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

divisors=[]
for d in range(1,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: Wrong Answer

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

limit=int(m**(1/2))+1
ans=0
for d in range(1,limit):
    if m%d==0 and m-d*(n-1)>0:
        ans=d
print(ans)

Submission status: Wrong Answer

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

limit=int(m**(1/2))
ans=0
for d in range(1,limit):
    if m%d==0 and m-d*(n-1)>0:
        ans=d
print(ans)

Submission status: Wrong Answer

Solution code:
def divisors(N):
    U = int(N ** 0.5)
    res = []
    all(res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Submission status: Wrong Answer

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

U = M // N
D = 1
for d in range(2, int(M ** 0.5) + 1):
    q, r = divmod(M, d)
    if r == 0:
        D = max(D, d if d <= U else 0, q if q <= U else 0)
print(D)

Submission status: Wrong Answer

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

D = 1
for d in range(2, M // N + 1):
    if M % d == 0:
        D = max(D, d)
    if d * d > M:
        break
print(D)

Submission status: Wrong Answer

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

D = 1
for d in range(2, M // N + 1):
    if M % d == 0:
        D = d
    if d * d > M:
        break
print(D)

Submission status: Wrong Answer

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 range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Submission status: Wrong Answer

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:
    ans = []
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().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
if M % N == 0:
    ans = M // N
else: 
    max_fact = 0
    for i in factorize(M):
        if i[0]**i[1] > max_fact:
            max_fact = i[0]**i[1]
    ans = M // max_fact
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
M2 =int(M ** (1/2) // 1 + 1)

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

ans = 1
for i in range(1, M2):
  if M % i == 0:#iがMの約数のとき、最大公約数となる可能性がある。
    Sho = M // i
    if Sho >= N:
      ans = i
      
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
M2 =int(M ** (1/2) // 1 + 1)

ans = 1
for i in range(1, M2):
  if M % i == 0:#iがMの約数のとき、最大公約数となる可能性がある。
    Sho = M // i
    if Sho >= N:
      ans = i
      
print(ans)

Submission status: Wrong Answer

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())
ans = 1
DIV = make_divisors(N)
print(DIV)

for i in DIV:
    if M - i*N >= 0:
        ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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().split())
print(solve(N, M))

Submission status: Wrong Answer

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().split())
print(solve(N, M))

Submission status: Wrong Answer

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))):
        q, r = divmod(M, n)
        if r != 0:
            continue
	# n と q は M の約数 n < q
        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().split())
print(solve(N, M))

Submission status: Wrong Answer

Solution code:


# N < 10^5
# N <= M <= 10^9
from math import sqrt, ceil
def solve(N, M):
    p = 1
    for n in range(2, ceil(sqrt(M))):
        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().split())
print(solve(N, M))

Submission status: Wrong Answer

Solution code:
import sys

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

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

divisors = make_divisors(n)
for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n, m = map(int, input().split(' '))
     
h = int(m/n)+1
x = 0

if h%2 == 0:
    if m%h == 0:
        print(h)
        sys.exit()
    h -= 1
    for a in range(h, 0, -2):
        if a*n <= m:
            if m%a == 0:
                print(a)
                sys.exit()
        else:
            continue
else:
    if m%h == 0:
        print(h)
        sys.exit()
    for a in range(h, 0, -2):
        if a*n <= m:
            if m%a == 0:
                print(a)
                sys.exit()
        else:
            continue

Submission status: Wrong Answer

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

h = int(m/n)+1
x = 0
result = [x for x in range(h, 0, -1) if m%x==0]
print(max(result))

Submission status: Wrong Answer

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

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    if m%a == 0:
        print(a)
        break
    else:
        continue

Submission status: Wrong Answer

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

h = int(n/2)+1

for i in range(h, 0, -1):
    if m%i == 0:
        q = m-i*n
        if q%i == 0:
            print(i)
            break
        else:
            continue

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
g = []
for i in range(1,M+1):
  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: Wrong Answer

Solution code:
from math import factorial

def divisors(n):
    e = int(n**0.5+1)
    k = int(0)
    div=[0]*e
    for i in range(1,e):
        if n%i == 0:
            div[k] = i
            k +=1

    i = int(0)
    while div[i]!=0 : i +=1
    end=int(i)

    del div[end:]

    return(div)

N, M = map(int, input().split())
L = divisors(M)
maxans = int(M//N)

anst = int(0)
for i in L:
    if i > maxans:
        break
    else:anst = i

ans = anst
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ans = 0
  x = M
  for i in range(1,b+1):
    x -= N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  ans = 0
  x = M
  for i in range(1,(b+1)//2+1):
    x -= N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  for i in range(1,c+1):
    if c%i==0:
      ls += [i]
  m = 0
  for l in ls:
    if b%l==0:
      m = l
  print(m)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  for i in range(1,c+1):
    if c%i==0:
      ls += [i]
  m = 0
  for l in ls:
    if b%l==0:
      m = l
  print(l)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  g = 0
  for i in range(1,c+1):
    if c%i==0:
      if g<gcd(c//i,b):
        g = gcd(c//i,b)
  print(g)

Submission status: Wrong Answer

Solution code:
import math
def composite(n):
  sq = math.sqrt(n)
  flag = 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])
    break

Submission status: Wrong Answer

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

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

    # divisors.sort()
    return divisors

ans=(make_divisors(m))
ans.sort()

for i in range(len(ans)):
    if ans[i]>m//n:
        print(ans[i-1])
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

d = int(M**(1/2))+1
while d >= 1:
    if M%d == 0:
        print(d)
        break
    else:
        d -= 1

Submission status: Wrong Answer

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

d = int(M**(1/2))
while d >= 1:
    if M%d == 0:
        print(d)
        break
    else:
        d -= 1

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(m//n,1,-1):
        c=fractions.gcd(i,i+m-i*n)
        if c>ans:
            ans=c
            break
        else:
            continue
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(m//n,1,-1):
        c=fractions.gcd(i,m-i*n)
        if c>ans:
            ans=c
            break
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = (int(x) for x in input().split())
ans = []

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

Submission status: Wrong Answer

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

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

N,M = II()

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

ans = 1
a = M//N
kouho = make_divisors(M)
for i in kouho:
  if M%i==0 and i*N<=M:
    ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
setrecursionlimit(10**6)

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
k = 0
length = 0
if n == 1:
    print(m)
else:
    length = min(int(m / n) + 1, int(m/2 ) + 1)
for i in range(1, length):
    if m % i == 0:
        k = i
print(k)

Submission status: Wrong Answer

Solution code:
from fractions import*;n,m=map(int,input().split());print(gcd(m//n,m%n))

Submission status: Wrong Answer

Solution code:
# 2019/08/01


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

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

res=divisors(n,m)
for e in res:
    if m//n>=e:
        print(e)
        break

Submission status: Wrong Answer

Solution code:
# 2019/08/01


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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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