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:
primes = []
MAX_NUM = 100000
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
for num in range(MAX_NUM):
    if is_prime[num]:
        primes.append(num)
        for j in range(2*num, MAX_NUM, num):
            is_prime[j] = False

def do_prime_factorization(x):
    ps = []
    i = 0
    n = len(primes)
    while (x > 1) and (i < n):
        p = primes[i]
        while x % p == 0:
            x /= p
            ps.append(p)
        i += 1
    if x > 1:
        ps.append(p)
    res = {}
    for p in ps:
        if not p in res:
            res[p] = 0
        res[p] += 1
    return res

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d >= len(ps):
        return m
    p, num = ps.items()[d]
    res = m
    for i in range(num+1):
        y = x * (p**i)
        res = min(res, f(y, d+1, n, m, ps))
    return res

def solve(n, m):
    ps = do_prime_factorization(m)
    if m in ps:
        return 1
    q = f(1, 0, n, m, ps)
    p = m // q
    return p

n, m = map(int, raw_input().split())
print(solve(n, m))

Submission status: Wrong Answer

Solution code:
primes = []
MAX_NUM = 100000
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
for num in range(MAX_NUM):
    if is_prime[num]:
        primes.append(num)
        for j in range(2*num, MAX_NUM, num):
            is_prime[j] = False

def do_prime_factorization(x):
    ps = []
    i = 0
    n = len(primes)
    while (x > 1) and (i < n):
        p = primes[i]
        while x % p == 0:
            x /= p
            ps.append(p)
        i += 1
    if x > 1:
        ps.append(p)
    res = {}
    for p in ps:
        if not p in res:
            res[p] = 0
        res[p] += 1
    return res

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d >= len(ps):
        return m
    p, num = ps.items()[d]
    res = m
    for i in range(num+1):
        y = x * (p**i)
        res = min(res, f(y, d+1, n, m, ps))
    return res

def solve(n, m):
    ps = do_prime_factorization(m)
    q = f(1, 0, n, m, ps)
    # assert m % q == 0, (m, q)
    p = m // q
    return p

n, m = map(int, raw_input().split())
print(solve(n, m))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
a = M // N
x = 1

for i in range(1, a + 1):
    if M % i == 0:
        x = i

print(i)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ps = range(1, N + 1)
candidates = []
for p in ps:
    if M % p == 0:
        if M // p >= N:
            candidates.append(p)
        if p >= N:
            candidates.append(M // p)
print(max(candidates))

Submission status: Wrong Answer

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

if N==1:
    print(M)
else:
    ans=1
    for i in range(2,10**5):
        if M%i==0:
            if M>=N*i:
                if ans<i:
                    ans=i
                
    print(ans)

Submission status: Wrong Answer

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

if N==1:
    print(M)
else:
    ans=1
    for i in range(2,10**5):
        if M%i==0:
            if M/i>=N:
                if ans<i:
                    ans=i
                
    print(ans)

Submission status: Wrong Answer

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

if n==1:
  print(m)
else:
  a=int(m**0.5)

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

Submission status: Wrong Answer

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

if n==1:
  print(m)
else:
  a=int(m**0.5)

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

Submission status: Wrong Answer

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

if n==1:
  print(m)
else:
  a=int(m**0.5)

  for i in range(a+1,0,-1):
    if m%i==0 and i*n<=m:
      print(i)
      break

Submission status: Wrong Answer

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

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=set(prime_decomposition(m))

for i in a:
  if n*i<m:
    print(i)
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,math.floor(math.sqrt(M))+1):
    if M % i == 0:
        L.append(i)
        L.append(M / i)
L1 = [i for i in L if M / i >= N]
print(max(L1))

Submission status: Wrong Answer

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


ans=1

for i in range(1,min(M//N+100,10**5+5)):
    if M%i==0 and M/N>=i:
            ans=i
print(ans)

Submission status: Wrong Answer

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


ans=1

for i in range(1,min(M//N+100,10**5+5)):
    if M%i==0:
            ans=i
print(ans)

Submission status: Wrong Answer

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


ans=1

for i in range(1,min(M//N+1,10**5+5)):
    if M%i==0:
            ans=i
print(ans)

Submission status: Wrong Answer

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

maxv=M//N
ans=0

for i in range(1,int(math.sqrt(M))):
    if M%i==0:
        if i<=maxv:
            ans=max(ans,i)
        j=M//i
        if j<=maxv:
            ans=max(ans,j)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M = map(int,input().split())
Max = 1
for m in range(1,int(math.sqrt(M))+1):
    if M%m == 0 and m <= M//N and Max < m:
        Max = m
        if M//m <= M//N and Max <M//m :
            Max = M//m
            
print(Max)

Submission status: Wrong Answer

Solution code:
import math
N,M = map(int,input().split())
Max = 1
for m in range(1,int(math.sqrt(M))+1):
    if M%m == 0 and m <= M//N and Max < m:
        Max = m
        if M//m <= M//N and Max <m :
            Max = m
            
print(Max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=0

for i in range(1,10**5):
    if M<N*i:
        break
    elif M%i==0:
        if M>=N*i:
            ans=i
print(ans)

Submission status: Wrong Answer

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

ans=1

for i in range(2,10**5):
    if (M/i)<N:
        break
    elif M%i==0:
        if M/i>=N:
            ans=i
print(ans)

Submission status: Wrong Answer

Solution code:
n, m =map(int, input().split())
a=m//n
c=0
if(n==1):
  c=m
if(m<a**2):
  a=int(m**0.5)
while c==0:
  if(m%a==0):
      c=a
  a=a-1
print(c)

Submission status: Wrong Answer

Solution code:
n, m =map(int, input().split())
a=m//n
c=0
if(m<a**2):
  a=int(m**0.5)
while c==0:
  if(m%a==0):
      c=a
  a=a-1
print(c)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().strip().split()))
num = N
i = 1

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    ans = []
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return sorted(ans)

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

facts = factoring(m)
ans = 1
for i in facts[::-1]:
    if (i <= int(m/n)) and ((m - i*n)%i == 0):
        print(i)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    ans = []
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return sorted(ans)

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

facts = factoring(m)
ans = 1
for f in facts[::-1]:
    if f <= int(m/n):
        print(f)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    ans = []
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return ans

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

facts = factoring(m)
ans = 1
for f in facts[::-1]:
    if f <= int(m/n):
        ans = max(ans, f)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return ans

n, m = map(int, input().split())
ans = []

facts = factoring(m)
for f in facts[::-1]:
    if f <= int(m/n):
        print(f)
        exit()

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return ans

n, m = map(int, input().split())
ans = []

facts = factoring(m)
for f in facts[::-1]:
    if f <= m/n:
        print(f)
        exit()

Submission status: Wrong Answer

Solution code:
import math

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

p = []

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

ret = 1
for i in p:
    if m // i >= n:
        ret = i
#print(p)
print(ret)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
n,m=map(int,input().split())
if n==1:
    print(m)
    sys.exit()
print(max([i for i in range(1,int(math.sqrt(m))) if m%i==0 and m/i>=n]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) == 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

print(cnt)
print(list(itertools.product(*tmp_list)))
for p in itertools.product(*tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        tmp = tmp * (k ** i)

    if tmp > N:
        ans_list.append(M//tmp)

if len(ans_list) == 0:
    print(1)
else:
    print(max(ans_list))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

# prod = itertools.product(*tmp_list)
# print(tmp_list)
# print(list(prod))
# print(prod)
for p in itertools.product(*tmp_list):
    # print(cnt.keys(), p)
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        # print(k,i)
        tmp = tmp * (k ** i)

    if tmp >= N:
        ans_list.append(M//tmp)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

# prod = itertools.product(*tmp_list)
# print(tmp_list)
# print(list(prod))
# print(prod)
for p in itertools.product(*tmp_list):
    # print(cnt.keys(), p)
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        # print(k,i)
        tmp = tmp * (k ** i)

        if tmp >= N:
            ans_list.append(M//tmp)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

for p in itertools.product(tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),*p):
        tmp = tmp * (k ** i)

        if tmp >= N and tmp > 1:
            ans_list.append(M//tmp)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

for p in itertools.product(tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),*p):
        tmp = tmp * (k ** i)

        if tmp >= N:
            ans_list.append(M//tmp)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

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

for i in reversed(range(1,div)):
    an = M - i*(N-1)
    if an % i == 0:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import math
N, M = list(map(int, input().split()))
if N == 1:
  print(M)
  exit()
X = int(math.sqrt(M))+1
for i in range(N, X):
  if M % i == 0:
      print(int(M/i))
      exit()
for i in range(N, 0, -1):
  if M % i == 0:
      print(i)
      exit()
print(1)

Submission status: Wrong Answer

Solution code:
import math
N, M = list(map(int, input().split()))
if N == 1:
  print(M)
  exit()
X = int(math.sqrt(M))+1
for i in range(N, X):
  if M % i == 0:
      print(int(M/i))
      exit()
print(1)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
g=1
for i in range(1,int(M**(1/2))+1):
  if M%i==0:
    if i>=N:
      g=M/i
      print(g)
      exit()
    elif i<=M/N:
      g=i
print(int(g))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
g=1
for i in range(1,int(M**(1/2))+1):
  if M%i==0:
    if i>=N:
      g=M/i
      print(g)
      exit()
    elif i<=M/N:
      g=i
print(g)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
g=1
for i in range(1,int(M**(1/2))):
  if M%i==0:
    if i>=N:
      g=M/i
      print(g)
      exit()
    elif i<=M/N:
      g=i
print(g)

Submission status: Wrong Answer

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder
'''
if Q>R :
    k=int((Q-R)//(1+N))
    k-=1
    Q -= k
    R += k*N
    '''

while R%Q != 0:
    k= int(Q//(N+R//Q+1))#max k:k*(N+R//Q)<Q-k
    #print(R,Q,R%Q,R//Q,k)
    if k != 0:
        Q -= k
        R += k*N
    else:
        Q -= 1
        R += N

print(Q)

Submission status: Wrong Answer

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


def divisor(m):
    ans = []
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
lim = m / n
for i in range(len(divs)):
    if divs[i] * n > m:
        print(divs[i - 1])
        break

Submission status: Wrong Answer

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


def divisor(m):
    ans = []
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
lim = m / n
for i in range(1, len(divs)):
    if divs[i] > lim:
        print(divs[i - 1])
        break

Submission status: Wrong Answer

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


def divisor(m):
    ans = []
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
lim = m / n
for i in range(len(divs)):
    if divs[i] > lim:
        break

print(divs[i - 1])

Submission status: Wrong Answer

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


def divisor(m):
    ans = []
    for i in range(1, math.floor(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
lim = m // n
for i in range(len(divs)):
    if divs[i] > lim:
        break

print(divs[i - 1])

Submission status: Wrong Answer

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder
if Q>R:
    k=int((Q-R)//(1+N))
    Q -= k
    R += k*N
while R%Q != 0:
    Q -= 1
    R += N


print(Q)

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(set(M//j for j in divisor_set if special_value >= M/j))
    print(int(max(list(divisor_set))))

    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set if special_value >= M/j)
    print(int(max(list(divisor_set))))
    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0) and (special_value >= i))
    divisor_set = divisor_set.union(M/j for j in divisor_set if (special_value >= M/j))
    print(max(list(divisor_set)))
    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M/N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 2)) if (M % i == 0) and (special_value >= i)]
    divisor_list = sorted(divisor_list)
    print(divisor_list[-1])
    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 2)) if (M % i == 0) and (special_value >= i)]
    divisor_list = sorted(divisor_list)
    print(divisor_list[-1])
    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 2)) if (M % i == 0) and (special_value >= i)]
    print(divisor_list[-1])
    return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 2)) if (M % i == 0)]
    for divisor in reversed(divisor_list):
        if (special_value >= divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0)]
    divisor_list.sort()
    for divisor in reversed(divisor_list):
        if (special_value >= divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0)]
    divisor_list.append(M)
    for divisor in reversed(divisor_list):
        if (special_value >= divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_list = [i for i in range(1, int(sqrt(M)) + 1) if (M % i == 0)]
    for divisor in reversed(divisor_list):
        if (special_value >= divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_list = [i for i in range(1, int(sqrt(M)) + 1) if (M % i == 0)]
    for divisor in reversed(divisor_list):
        if (special_value >= divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_list = [i for i in range(1, int(sqrt(M))) if (M % i == 0)]
    for divisor in reversed(divisor_list):
        if (special_value > divisor):
            print(divisor)
            return

main()

Submission status: Wrong Answer

Solution code:
import itertools

def prime(M):
    lst = []
    i = 2
    while M != 1:
        if M % i == 0:
            lst.append(i)
            M = M // i
        else:
            i += 1
    return lst

def volume(lst):
    res = 1
    for i in lst:
        res *= int(i)
    return res


N, M = map(int, input().split())
lst = prime(M)
res_lst = []
for i in range(len(prime(M)) + 1):
    for j in itertools.combinations(lst, i):
        if not volume(j) in res_lst:
            res_lst.append(volume(j))
res_lst = sorted(res_lst)
res = 1
for num in res_lst:
    if N < num:
        break
    else:
        res = num

print(res)

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    divisor = []
    n = int(math.sqrt(M))
    for i in range(1, n):
        if M % i == 0:
            tmp = M / i
            if not i in divisor:
                divisor.append(i)
            if not tmp in divisor:
                divisor.append(tmp)

    maximize = 0
    threshold = int(M / N)
    for item in divisor:
        if item <= threshold and maximize < item:
            maximize = item

    print(maximize)

Submission status: Wrong Answer

Solution code:
import math

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

divisor = []
n = int(math.sqrt(M))
for i in range(1, n):
    if M % i == 0:
        tmp = M / i
        if not i in divisor:
            divisor.append(i)
        if not tmp in divisor:
            divisor.append(tmp)

maximize = 0
threshold = int(M / N)
for item in divisor:
    if item <= threshold and maximize < item:
        maximize = item

print(maximize)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
i=10000
max=0
while M<N*i:
    i -=1
while M>=N*i:
    if M%i==0:
        if (M-i*N)%i==0 and (M-i*N)>=0:
            max=i
            break
    else:
        i -=1
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def soinsuubunkai(n):
    i = 2
    list = [1]
    while i**2 <= n:
        if n%i == 0:
            list.append(i)
            if i != n//i:
                list.append(n//i)
        i += 1
    list.append(n)
    return list
n, m = map(int, input().split())
l = soinsuubunkai(m)
r = len(l)
for i in range(r):
    if m//l[r-i-1] >= n:
        print(l[r-i-1])
        quit()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
for i in range(min(kouyaku_max,int(m**0.5)),0,-1):
    if ((m % (i) == 0) and (n*i <= m)):
        kouyaku = i
        break

print('{}'.format(kouyaku))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
for i in range(min(kouyaku_max,int(m**0.5)),0,-1):
    if ((m % (i) == 0) and n*i <= m):
        kouyaku = i
        break

print('{}'.format(kouyaku))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
for i in range(min(kouyaku_max,int(n**0.5)),0,-1):
    if ((m % (i) == 0) and n*i < m):
        kouyaku = i
        break

print('{}'.format(kouyaku))

Submission status: Wrong Answer

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

print('{}'.format(kouyaku))

Submission status: Wrong Answer

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

print('{}'.format(kouyaku))

Submission status: Wrong Answer

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

print('{}'.format(kouyaku))

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
kouyaku_max = min(m // n, math.floor(math.sqrt(m))+1)
kouyaku = 1
if n != 1:
    for i in reversed(range(kouyaku_max)):
        if (m % (i + 1) == 0):
            kouyaku = i + 1
            break
else:
    kouyaku = m
print('{}'.format(kouyaku))

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
for i in reversed(range(math.floor(m))):
    if (m % (i + 1) == 0):
        kouyaku = i + 1
        break

print('{}'.format(kouyaku))

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
tmp = math.floor(math.sqrt(m))
range_kou = min(kouyaku_max, tmp)
for i in reversed(range(range_kou)):
    if (m % (i + 1) == 0):
        kouyaku = i + 1
        break
if n == 1:
    kouyaku = m

print('{}'.format(kouyaku))