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

sup = m//n + 1

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

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()

ans = 1
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0 and i <= (m / n):
        ans = i

print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()

ans = 1
for i in range(1, int(m ** 0.5)):
    if m % i == 0 and i <= (m / n):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = 100000
m = 1000000000
pq_max = 0

for p in range(1, int(math.sqrt(m)) + 1):
    if m % p == 0:
        q = m // p
        
        if p >= n and q > pq_max:
            pq_max = q
            
        if q >= n and p > pq_max:
            pq_max = p
        
print(pq_max)

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = []
n = 0
if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, int(math.sqrt(M))+1):
        if (M % i == 0):
            A.append(i)
            A.append(int(M / A[2*n]))
            n += 1
    for k in range(len(A)):
        if A[-1-k] <= M//N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = []
n = 0
if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, int(math.sqrt(M))):
        if (M % i == 0):
            A.append(i)
            A.append(int(M / A[2*n]))
            n += 1
    for k in range(len(A)):
        if A[-1-k] <= M//N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = []
n = 0
if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, int(math.sqrt(M))):
        if (M % i == 0):
            A.append(i)
            A.append(int(M / A[2*n]))
            n += 1
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = []
n = 0
if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, int(math.sqrt(M))):
        if (M % i == 0):
            A.append(i)
            A.append(int(M / A[2*n]))
            n += 1
    print(A)
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, math.floor(pow(M,0.5))+1):
        if (M % i == 0):
            A.append(i)
    for j in range(len(A)):
        A.append(int(M/A[j]))
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, math.floor(pow(M,0.5))):
        if (M % i == 0):
            A.append(i)
    for j in range(len(A)):
        A.append(int(M/A[j]))
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, math.floor(pow(M,0.6))):
        if (M % i == 0):
            A.append(i)
    for j in range(len(A)):
        A.append(int(M/A[j]))
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, math.floor(pow(M,0.55))):
        if (M % i == 0):
            A.append(i)
    for j in range(len(A)):
        A.append(int(M/A[j]))
    for k in range(len(A)):
        if A[-1-k] <= M/N:
            print(A[-1-k])
            exit()

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, math.floor(pow(M,0.55))):
        if (M % i == 0) and (i <= M/N):
            A.append(i)
    print(A[-1])

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, M):
        if i > math.floor(pow(M,0.7)):
            print(ans)
            exit()
        if M % i == 0:
            if M / i < N:
                print(ans)
                exit()
            else:
                ans = i

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, M):
        if i > math.floor(pow(M,0.6)):
            print(ans)
            exit()
        if M % i == 0:
            if M / i < N:
                print(ans)
                exit()
            else:
                ans = i

Submission status: Wrong Answer

Solution code:
import math

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

if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, M):
        if i > math.floor(pow(M,0.5)):
            print(ans)
            exit()
        if M % i == 0:
            if M / i < N:
                print(ans)
                exit()
            else:
                ans = i

Submission status: Wrong Answer

Solution code:
import math

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(int(math.sqrt(m)),0,-1):
    if (m%i==0 and n<=m//i):
       print(i)
       exit(0)

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    while True:
        if M%s == 0:
            a = M//s
            if a <= M//N:
                print(max(s, M//s))
            else:
                print(s)
            break
        s -= 1



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    while True:
        if M%s == 0:
            print(max(s, M//s))
            break
        s -= 1



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    while True:
        if M%s == 0:
            print(s)
            break
        s -= 1



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    r = M - N*s
    while True:
        if r >= 0 and r%s == 0:
            print(s)
            break
        s -= 1
        r += N



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = math.ceil(math.sqrt(M))
    r = M - N*s
    while True:
        if r >= 0 and r%s == 0:
            print(s)
            break
        s -= 1
        r += N



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N, M = map(int, input().split())
x = M // N
cd = 1
flag = 1

for i in primes(N):
  if M % i == 0:
    flag = 0
    break
if flag:
  x = 0
    
while x:
  if M % x == 0:
    cd = x
    break
  x -= 1
print(cd)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
x = M // N + 1
cd = 1
while x:
  if M % x == 0:
    cd = x
    break
  x -= 1
print(cd)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
x = M // N + 1
while True:
  if M % x == 0:
    cd = x
    break
  x -= 1
print(cd)

Submission status: Wrong Answer

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  H = 1
  for i in range(int(M//N)+1, 1, -1):
    if M % i == 0:
      H = i
      break

  print(H)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  O = [0, 1] + [0 for _ in range(int(M**0.5)+1)]
  H = 1
  for i in range(int(M**0.5)+1, 1, -1):
    while M % i == 0:
      if (M // i) < N:
        break
      else:
        M //= i
        H *= i
  print(H)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  O = [0, 1] + [0 for _ in range(int(M**0.5)+1)]
  H = 1
  for i in range(int(M**0.5)+1, 2, -1):
    while M % i == 0:
      if (M // i) < N:
        break
      else:
        M //= i
        H *= i
  print(H)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
X=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if m/n >=i:
            X.append(i)

            
print(max(X))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = 1
if n != 1:
    for i in range(1, min(m // n + 1, int(m ** 0.5) + 2))[::-1]:
        if m % i == 0:
            ans = max(ans, i)
            if i >= n:
                ans = max(ans, m // i)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M =[int(i)for i in input().split()]
l=[1]
for i in range(2,int(M**0.5+1)):
    if M%i==0:
        if M/i >= N:
            l.append(i)
        if i >= N:
            l.append(M/i)
print(int(max(l)))

Submission status: Wrong Answer

Solution code:
N,M =[int(i)for i in input().split()]
l=[1]
for i in range(2,int(M**0.5+1)):
    if M%i==0:
        if M/i >= N:
            l.append(i)
        if i >= N:
            l.append(M/i)
print(max(l))

Submission status: Wrong Answer

Solution code:
# できなかった
# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
n,m=map(int,input().split())

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

divisors.sort(key=lambda x:-x)
# print(divisors)
for d in divisors:
    if d<m//n:
        print(d)
        break

Submission status: Wrong Answer

Solution code:
# できなかった
# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
n,m=map(int,input().split())

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(key=lambda x:-x)
for d in divisors:
    if d<m//n:
        print(d)
        break

Submission status: Wrong Answer

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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

Submission status: Wrong Answer

Solution code:
nm=[int(x) for x in input().split()]
for x in range(int(nm[1]/nm[0]),1,-1):
    if(nm[1]%x==0):
        print(x)
        break

Submission status: Wrong Answer

Solution code:
nm=[int(x) for x in input().split()]
for x in range(int(nm[1]/nm[0]),1,-1):
    print(x)
    if(nm[1]%x==0):
        print(x)
        break

Submission status: Wrong Answer

Solution code:
nm=[int(x) for x in input().split()]
for x in range(int(nm[1]/nm[0])+1,1,-1):
    if(nm[1]%x==0 and (nm[1]/x)>=nm[0]):
        print(x)
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

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

ans = 1
x = 1
a = []

while x * x <=M:
 if M%x==0:
  a.append(x)
  a.append(M/x)
  print x, M/x
 x+=1
 

print x, a
for i in a:
 if M/i >= N:
  ans = max(ans,i)
print ans

Submission status: Wrong Answer

Solution code:
import math

n,m = map(int, input().split())
limit = m+1 if m < 4 else math.ceil(math.sqrt(m))

for i in range(1, limit):
    if m % i != 0:
        continue
    if m // i < n:
        continue
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n,m = map(int, input().split())
limit = m+1 if math.sqrt(m) < 4 else math.ceil(math.sqrt(m))

for i in range(1, limit):
    if m % i != 0:
        continue
    if m // i < n:
        continue
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if m // i < n:
        continue
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math

inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
m =1
for i in range(1,k//2+1)[::-1]:
    if k%i==0 and k//i>=n:
        m= i
        break
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
m =1
for i in range(1,int(math.sqrt(k))+1)[::-1]:
    if k%i==0:
        m= i
        break
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
flag = True
N, M = map(int, input().split())
ans = 0
for i in range(1, int(np.sqrt(M)) + 2):
    if M % i == 0 and M // i >= N:
        ans = max(ans, i)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N==1:
  print(M)
else:
  for i in range(M-N):
    k = i + N
    if M % k == 0:
      print(int(M/k))
      tmp=1
      break

if tmp==0:
  print(1)

Submission status: Wrong Answer

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

for i in range(M-N):
  k = i + N
  if M % k == 0:
    print(int(M/k))
    break

  print(1)

Submission status: Wrong Answer

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

for i in range(int(M/N)+1):
  k = i + N
  if M % k == 0:
    print(int(M/k))
    break

print(1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(M-N):
  k = i + N
  if M % k == 0:
    print(int(M/k))
    break

Submission status: Wrong Answer

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

for i in range(M-N):
  k = i + N
  if M % k == 0:
    print(int(M/k))
    break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(M-N):
  k = i + N
  if M % k == 0:
    print(M/k)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        return
    i = 1
    ans = 1
    while i*i <= m:
        if m % i != 0:
            i += 1
            continue
        a = i
        if m / i >= n:
            ans = max(ans, i)
        if m / (m / i) >= n:
            ans = max(ans, i)
        i += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    ans = 0
    for i in range(1, int(M ** 0.5)):
        if M % i != 0:
            continue
        if M >= i * N:
            ans = max(i, ans)
        if M >= M // i * N:
            ans = max(M // i, ans)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(1, min(M//N+2,int(math.sqrt(M))+2)):
    if M%i==0:
        ans=i
    
print(ans)

Submission status: Wrong Answer

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

for i in range(1, min(M//N+2,int(math.sqrt(M))+1)):
    if M%i==0:
        ans=i
    
print(ans)

Submission status: Wrong Answer

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

ans=1
i=2

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

print(ans)

Submission status: Wrong Answer

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

a = M//N
b = M%N    
    
print(fractions.gcd(a,b))

Submission status: Wrong Answer

Solution code:
N ,M= input().split()
N = int(N)
M = int(M)
if N == 1:
    print(M)
else:
    sei = M // N
    yo = M % N

    isPrime = True
    for x in range(2, M):
        if M % x == 0:
            isPrime = False
            break

    if isPrime or N == M:
        print(1)
    else:
        seigrds = []
        for x in range(1, sei+1):
            if sei % x == 0:
                seigrds.append(x)

        yogrds = []
        for x in range(1, yo+1):
            if yo % x == 0:
                yogrds.append(x)

        if len(yogrds) == 0:
            print(seigrds[-1])
        else:
            yogrds = sorted(yogrds, reverse = True)
            for x in yogrds:
                if x in seigrds:
                    print(x)
                    break

Submission status: Wrong Answer

Solution code:
N ,M= input().split()
N = int(N)
M = int(M)
sei = M // N
yo = M % N

seigrds = []
for x in range(1, sei+1):
    if sei % x == 0:
        seigrds.append(x)

yogrds = []
for x in range(1, yo+1):
    if yo % x == 0:
        yogrds.append(x)

if len(yogrds) == 0:
    print(seigrds[-1])
else:
    yogrds = sorted(yogrds, reverse = True)
    for x in yogrds:
        if x in seigrds:
            print(x)
            break

Submission status: Wrong Answer

Solution code:
N ,M= input().split()
N = int(N)
M = int(M)
sei = M // N
yo = M % N

seigrds = []
for x in range(1, sei+1):
    if sei % x == 0:
        seigrds.append(x)

yogrds = []
for x in range(1, yo+1):
    if yo % x == 0:
        yogrds.append(x)

if len(yogrds) == 0:
    print(seigrds[-1])
else:
    yogrds = sorted(yogrds, reverse = True)
    print(yogrds)
    for x in yogrds:
        if x in seigrds:
            print(x)
            break

Submission status: Wrong Answer

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

upper = m//n
ans = 0
for i in reversed(range(1, upper+1)):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)

Submission status: Wrong Answer

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

ans = 1
upper = m/n
for i in range(1, (int)(math.sqrt(m))+1):
    if m % i == 0:
        if i <= upper:
            ans = max(ans, i)

print(ans)

Submission status: Wrong Answer

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

ans = 1
upper = m/n+1
for i in range(2, (int)(math.sqrt(m))+1):
    if m % i == 0:
        if i < upper:
            ans = max(ans, i)

print(ans)

Submission status: Wrong Answer

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

ans = 0
upper = m//n+1
for i in range(1, (int)(math.sqrt(m))+1):
    if m % i == 0:
        if i <= upper:
            ans = max(ans, i)

print(ans)

Submission status: Wrong Answer

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

upper = (int)(math.sqrt(m/n))
for i in reversed(range(1, upper+1)):
    if m % i == 0:
        print(i)
        exit()

Submission status: Wrong Answer

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

i=1
while i*i <= M:
  if M % i == 0:
    if M // i <= M // N:
      maxg = M // i
      break
    else:
      maxg = i
  i += 1

print(maxg)

Submission status: Wrong Answer

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

i=1
while i*i <= M and i <= M//N:
  if M % i == 0:
    maxg = i
  i += 1

print(maxg)

Submission status: Wrong Answer

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

if m % n ==0:
    ans = a
    exit()

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

Submission status: Wrong Answer

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

for i in range(1, a + 1):
    if m % i == 0:
      if (m // i) > i and (m // i) <= a:
            ans = m // i
            break
        
print(ans)

Submission status: Wrong Answer

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

for i in range(2, a + 1):
    if m % i == 0:
        ans = i
        
        if (m // i) > i and (m // i) <= a:
            ans = m // i
            break
        
print(ans)

Submission status: Wrong Answer

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

if m % n == 0:
    ans = m // n

else:
    for i in range(2, m//2+1):
        if m % i == 0:
            A.append(i)
    
    for i in A:
        if i >= n:
            ans = m // i
            break
        
print(ans)

Submission status: Wrong Answer

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

if m % n == 0:
    ans = m // n

else:
    for i in range(2, m//2+1):
        if m % i == 0:
            A.append(i)
    
    for i in A:
        if i >= n:
            ans = m // i
        
print(ans)

Submission status: Wrong Answer

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

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

        g2 = M / g
        if M % g2 == 0 and M / g2 >= N:
            ans = max(ans, int(g2))
    print(ans)

Submission status: Wrong Answer

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

if N == 1:
    print(M)
else:
    ans = 1
    for g in range(1, int(M ** 0.5) + 1):
        if M % g == 0 and M / g >= N:
            ans = max(ans, g)

        g2 = M / g
        if M % g2 == 0 and M / g2 >= N:
            ans = max(ans, int(g2))         
    print(ans)

Submission status: Wrong Answer

Solution code:
import math as m
N,M = map(int,input().split())
divisor = []
for i in range(2,m.floor(pow(M,1/2)) + 1):
  if M % i == 0:
    divisor.append(i)
    divisor.append(M // i)
ans = 1
for e in divisor:
  if e > ans and e <= M // N:
    ans = e
print(ans)

Submission status: Wrong Answer

Solution code:
import math as m
N,M = map(int,input().split())
for i in range(m.floor(pow(M,1/2)),0,-1):
  if M % i == 0 and i <= M // N:
    ans = i
    break
print(ans)

Submission status: Wrong Answer

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

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):
    res = {}
    for p in primes:
        if x == 1:
            break
        while x % p == 0:
            x /= p
            if not p in res:
                res[p] = 0
            res[p] += 1
    if x > 1:
        res[p] = 1
    return res.items()

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d < 0:
        return m
    p, num = ps[d]
    res = m
    for i in range(num+1):
        # y = x * (p**i)
        y = x
        for j in range(i):
            y *= p
        res = min(res, f(y, d-1, n, m, ps))
    return res

def solve(n, m):
    ps = do_prime_factorization(m)
    q = f(1, len(ps)-1, 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):
    res = {}
    for p in primes:
        if x == 1:
            break
        while x % p == 0:
            x /= p
            if not p in res:
                res[p] = 0
            res[p] += 1
    if x > 1:
        res[p] = 1
    return res.items()

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d < 0:
        return m
    p, num = ps[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 % n == 0:
        return m // n
    if m in ps:
        return 1
    q = f(1, len(ps)-1, 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):
    res = {}
    for p in primes:
        if x == 1:
            break
        while x % p == 0:
            x /= p
            if not p in res:
                res[p] = 0
            res[p] += 1
    if x > 1:
        res[p] = 1
    return res.items()

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d < 0:
        return m
    p, num = ps[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 % n == 0:
        return n
    if m in ps:
        return 1
    q = f(1, len(ps)-1, 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):
    res = {}
    for p in primes:
        if x == 1:
            break
        while x % p == 0:
            x /= p
            if not p in res:
                res[p] = 0
            res[p] += 1
    if x > 1:
        res[p] = 1
    return res.items()

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d < 0:
        return m
    p, num = ps[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, len(ps)-1, n, m, ps)
    p = m // q
    return p

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