Problem: 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.

Submission attempts (in order):
import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

# amax = M // N
L = get_div_list(M)


# ans = L[-1]

# print(ans)


import math

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

# N = 3
# M = 14

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]
print(L)

ans = L[-1]

print(ans)


import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

print(ans)


import math

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

N = 100000
M = 1000000000

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        return div_list


L = get_div_list(M)
L = [i for i in L if i * N <= M]
# print(L)


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

print(ans)


import math

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

def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

amax = M // N
L = get_div_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

# print(ans)


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

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

        return divisor_list

# amax = M // N
L = make_divisor_list(M)


# ans = L[-1]

# print(ans)


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:
    
        ans.append(i)
print(max(ans))

# ans2 = 1


#     
#         ans2 = i
#         break
# print(ans2)

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:
    
        ans.append(i)
print(max(ans))

# ans2 = 1


#     
#         ans2 = i
#         break
# print(ans2)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted