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:
N, M = map(int, input().split())

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

    # divisors.sort()
    return divisors

divisors = make_divisors(M)
divisors.sort()

for idx, a in enumerate(divisors):
    # print(a)
    if M / a >= N:
        continue
    else:
        if idx-1 < 0:
            print(1)
        else:
            print(divisors[idx-1])
        break
print(divisors[-1])

Submission status: Wrong Answer

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

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

    # divisors.sort()
    return divisors

divisors = make_divisors(M)
divisors.sort()

for idx, a in enumerate(divisors):
    # print(a)
    if M / a >= N:
        continue
    else:
        if idx-1 < 0:
            print(1)
        else:
            print(divisors[idx-1])
        break

Submission status: Wrong Answer

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

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

    # divisors.sort()
    return divisors

divisors = make_divisors(M)
divisors.sort()


for idx, a in enumerate(divisors):
    # print(a)
    if M / a >= N:
        continue
    else:
        print(divisors[idx-1])
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
U=int(min(M//N,M**(0.5)))+1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import fractions
input = sys.stdin.readline
M, N = [int(x) for x in input().split()]
a = N // M
b = N % M
print(fractions.gcd(a,b))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = (int(i) for i in input().split())

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

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

    ans = 1
    for i in range(2, M//N+1)[::-1]:
        cur = gcd(i, M - i*(N-1))
        if cur == 1:
            continue
        else:
            ans = max(ans, cur)
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = (int(i) for i in input().split())

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    print(gcd((M//N), (M % N)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


d = div(m)
ans = 0
for x, y in d:
    if y >= n:
        ans = max(ans, x)

print(ans)

Submission status: Wrong Answer

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


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


d = div(m)
ans = 0
for x, y in d:
    if y >= n:
        ans = x

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
div = []
for i in range(1, M + 1):
    if i * i > M:
        break
    if M % i == 0:
        div.append(i)
    if M % i == 0 and i != M // i:
        div.append(M // i)
div.sort()
div.reverse()
print(div)
for i in div:
    if M // i >= N:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
div = []
for i in range(1, M):
    if i * i > M:
        break
    if M % i == 0:
        div.append(i)
    if M % i == 0 and i != M // i:
        div.append(M // i)
div.sort()
div.reverse()
for i in div:
    if M // i >= N:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math

n,m = map(int,input().split())
roop = min(m//n,math.floor(math.sqrt(m)))

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

Submission status: Wrong Answer

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

#nが1のとき
if n == 1:
    print(m)
    exit()

"""素因数分解"""
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            #もし素因数を重複させたくないならここを加えてfct.append(b)を消す
            """
            if not b in fct:
                fct.append(b)
            """
            fct.append(b)
        b = b+1
    if n > 1:
        fct.append(n)
    return fct #リストが帰る

#素数なら
if len(factrize(m)) == 0:
    print(1)
    exit()

if m%n != 0:
    print(m%n)
else:
    print(m//n)

Submission status: Wrong Answer

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

if m%n != 0:
    print(m%n)
else:
    print(m//n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    index = bisect_left(divisors,max_answer)
    print(divisors[index-1])

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

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

Submission status: Wrong Answer

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

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())
divisors_list = make_divisors(M)
divisors_list.sort(reverse=True)
print(divisors_list)
for val in divisors_list:
    if val * N <= M:
        break
print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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:
            m += N


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


def main():
    N, M = map(int, input().split())
    s = (N+1)*N//2

    k = 0
    while k * s < M:
        k += 1  # 答えはk以下にある

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

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


main()

Submission status: Wrong Answer

Solution code:
from math import floor, sqrt


def make_prime_list(k):
    p = [True] * (k+1)
    p[0] = False
    p[1] = False
    for i in range(2, k+1):
        if p[i]:
            for j in range(i*2, k+1, i):
                p[j] = False
    return [i for i in range(k + 1) if p[i]]


def solve(n, m):
    ans = 0
    if m % n == 0:
        ans = m // n
    else:
        prime = make_prime_list(floor(sqrt(m)))
        prime_factor = [p for p in prime if m % p == 0]
        if len(prime_factor) > 0:
            ans = prime_factor[-1]
        else:
            ans = 1

    return ans


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 1
ans = 1
while i**2 < m:
    if m % i == 0 and m // i >= n:
        ans = i
    i += 1
print(ans)

Submission status: Wrong Answer

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

i = 2
ans = -1
while i**2 < m:
    if m % i == 0 and m // i >= n:
        ans = i
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
divs = set()
i = 1
if (N == 1):
    print(M)
else:
    while (i*i <= M):
        if (M//i * i == M):
            divs.add(i)
        i += 1
    for d in divs:
        if (d > M//N): continue
        rest = M - (N-1)*d
        ans = max(ans, gcd(d, rest))
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
divs = set()
i = 1
if (N == 1):
    print(M)
else:
    while (i*i <= M):
        if (M//i * i == M):
            divs.add(i)
        i += 1
    for d in divs:
        rest = M - (N-1)*d
        ans = max(ans, gcd(d, rest))
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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))
    if (ans != 1): break
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
#n nums with sum m 
def check(mi):
    small=mi*n 
    if small>m:
        return 0 
    diff=(m-small)
    return diff%mi==0 
maxi=0 
from math import sqrt as S
def get_div(m):
    if m==1:
        return []
    div=[1,m]
    for i in range(2,int(S(m))+1):
        if m%i==0:
            div.append(i)
            if i!=m//i:
                div.append(m//i)
    return div 
d=get_div(m)
maxi=0
for mi in d:
    if check(mi):
        maxi=max(maxi,mi)
print(maxi)

Submission status: Wrong Answer

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

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

D1 = make_divisors(M)
D2 = []
for e in D1:
    if e <= M//N+1:
        D2.append(e)


ans = 0
for i in D2:
    R = M-(i*N)
    if R%i == 0:
        ans = i
print(ans)

Submission status: Wrong Answer

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

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

x = min(M//N, int(M**0.5))
ans_list = []

while x > 0:
    if M % x == 0:
        ans_list.append(x)
    x -= 1
    
print(max(ans_list))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
tmp = M // N
ansMax = 0
y = []
for i in range(2, (int(M ** (0.5)) + 1)):
    if M % i == 0:
        y.append(i)
        if i != M // i:
            y.append(M // i)
y.sort()

for i in y:
    if i <= tmp:
        ansMax = i
    else:
        break
print(ansMax)

Submission status: Wrong Answer

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

ans = N
while True:
    if M % ans == 0:
        print(ans)
        break
    else:
        ans -= 1

Submission status: Wrong Answer

Solution code:
k,m=map(int,input().split())
ans=0
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table
a=prime_decomposition(m)
a.append(m)
for i in range(len(a)):
    if a[i]*k<m:
        ans=a[i]
if m%k==0:
    ans=int(m/k)
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ans = 1
for i in range(2, int(math.sqrt(M))+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: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ans = 1
for i in range(2, math.ceil(math.sqrt(M))+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: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ans = 1
for i in range(2, math.floor(math.sqrt(M))):
    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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ans = 1
for i in range(2, math.ceil(math.sqrt(M))//3):
    if M % i == 0:
        if M // i >= 1:
            ans = i
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ans = 1
for i in range(2, math.floor(math.sqrt(M))//3):
    if M % i == 0:
        if M // i >= 1:
            ans = i
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split(' ')))
p = []
ct = 2
hoge = M
while hoge > 1:
    r = ct
    while hoge % ct == 0:
        p.append(r)
        hoge = hoge // ct
        r *= ct
    ct += 1
    if ct >= 1e5:
        if M != 1:
            p.append(hoge)
        break
p.append(M)
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)

# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)

# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 1
for t in sorted(p):
    if M / N >= t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split(' ')))
p = []
ct = 2
hoge = M
while hoge > 1:
    r = ct
    while hoge % ct == 0:
        p.append(r)
        hoge = hoge // ct
        r *= ct
    ct += 1
    if ct >= 1e5:
        if M != 1:
            p.append(hoge)
        break
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)

# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)

# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 1
for t in sorted(p):
    if M / N >= t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split(' ')))
p = []
ct = 2
hoge = M
while hoge > 1:
    r = ct
    while hoge % ct == 0:
        p.append(r)
        hoge = hoge // ct
        r *= ct
    ct += 1
    if ct >= 1e5:
        if M != 1:
            p.append(hoge)
        break
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)

# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)

# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 1
for t in p:
    if M / N >= t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split(' ')))
p = []
for ct in range(2, 100000):
    if M % ct == 0:
        p.append(ct)
p.append(M)
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)

# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)

# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 1
for t in p:
    if M / N >= t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split(' ')))
p = []
for ct in range(2, 100000):
    if M % ct == 0:
        p.append(ct)
p.append(M)
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)

# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)

# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 0
for t in p:
    if M / N >= t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
K = m//n
ans = 0
i = 1
while i <= K:
  if m % i == 0:
    ans = i
    K = min(m//n, m//i)
  i += 1
print(ans)

Submission status: Wrong Answer

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

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

print(M // N)

Submission status: Wrong Answer

Solution code:
import math
def main():
    n,m = map(int,input().split())
    for i in range(n,math.ceil(math.sqrt(m))):
        if m%i==0:
            print(m//i)
            break
main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    n,m = map(int,input().split())
    for i in range(n,math.floor(math.sqrt(m))):
        if m%i==0:
            print(m//i)
            break
main()

Submission status: Wrong Answer

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

"""解き方
[入力例1]
N=3, M=14
a_1 + a_2 + a_3 = 14

14/3 = 4あまり2

よって、4 + 4 + 6のとき、最大公約数は2

[入力例2]
N=10, M=123

a_1 + a_2 + ... + a_10 = 123

123/10 = 12あまり3

よって、12 + 12 + 12 + ... + 12 + 15のとき、最大公約数は3

[入力例3]
同上

"""

from fractions import gcd

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

    base = M//N

    if M%N == 0:
        print(base)
        return
    else:
        last = base + M%N
        ans = gcd(base, last)
        print(ans)
        return



if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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


def prime_factorize(n):
    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


prime_list = prime_factorize(m)
max_ = 0
for i in prime_list:
    if i <= m/n and i > max_:
        max_ = i
print(max_)

Submission status: Wrong Answer

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

a = min(int(m /n),m//2)

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

Submission status: Wrong Answer

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

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 sorted(divisors, reverse=True)

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

    divisors = make_divisors(M)

    for d in divisors:
        tmp = M - d * N
        if tmp > 0 and tmp % d == 0:
            print(d)
            break
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
maxi=0
import math
num=math.sqrt(m)
nums=math.floor(num)

for i in range(1,nums+1):
    if m%i==0:
        number1=i
        number2=m//i
        #二つの約数について比べる
        if i<=m:
            if m//number1>=n and m//number2>=n:
                maxi=max(number1,number2)
            if m//number1>=n and m//number2<n:
                maxi=number1
            if m//number1<n and m//number2>=n:
                maxi=number2
            if m//number1<n and m//number2<n:
                continue 
        
    else:
        continue
        
print(maxi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

        
print(maxi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

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

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 range(1, math.ceil(M**0.5)+1):
        # 最大公約数がiとする
        rest = M - (i * N)
        if (i+rest) % i == 0:
            ans = max(i, ans)
else:
    if N == 1:
        ans = M
    else:
        ans = 1

print(ans)

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, int(M**0.5)+1)):
        # 最大公約数がiとする
        rest = M - (i * N)
        if (i+rest) % i == 0:
            ans = i
            break
else:
    if N == 1:
        ans = M
    else:
        ans = 1

print(ans)

Submission status: 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)+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)