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:
#coding:utf-8

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

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

result = []


def factorization(a):
    if a == 1:
        return
    for i in range(2, a + 1):
        if a % i == 0:
            result.append(i)
            factorization(int(a / i))
            return

#Mの素因数分解
factorization(M)
M_factors = result

#M_factorsの中で、N*αがM以下である最大となる因数αを算出
M_factors = [x for x in M_factors if N * x < M]

answer = 0


def search(M_factors, accept=[], reject=[]):
    global answer
    seki = 1
    for i in accept:
        seki *= i
    if N * seki > M:
        return
    if seki > answer:
        answer = seki
    if len(M_factors) == 0:
        return

    M_factors1 = M_factors.copy()
    M_factors2 = M_factors.copy()
    accept_ = accept.copy()
    reject_ = reject.copy()

    candidate = M_factors1.pop()
    accept_.append(candidate)
    search(M_factors1, accept_, reject)

    candidate = M_factors2.pop()
    reject_.append(candidate)
    search(M_factors2, accept, reject_)


search(M_factors)
print(answer)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = M//N
flag = False
L = []
if (99000000 <= M <= 999999999 and N <= 20):
  for i in range(1,1000000):
    if (M%i == 0):
      L.append(i)
  print(max(L))
else:
  for i in range(1,A+1):
    if (M%(A+1-i) == 0):
      flag = True
      break
  if flag:
    print(A+1-i)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if m % n == 0:
    print(n)
else:
    print(m % n)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if M % N == 0:
    ans = int(M/N)

elif M / N > 1000000:
    ans = 2

else:
    amax = M // N
    for i in range(amax, 0, -1):
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

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

if M % N == 0:
    print(int(M / N))
else:
    if (N % 2 == 1 & M % 2 == 0) | (N % 2 == 1 & M % 2 == 0):
        print(M % N)
    if (N % 2 == 1 & M % 2 == 1) | (N % 2 == 0 & M % 2 == 0):
        print(1)

Submission status: Wrong Answer

Solution code:
from math import ceil
n, m = map(int, input().split())
for i in range(m, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        break
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = m % n

if a == 0:
    print(int(m / n))
elif m % a == 0 and a != 1:
    print(a)
else:
    b = n

    while True:
        b = b + 1

        if m % b == 0:
            print(b)
            exit()

Submission status: Wrong Answer

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

if M % N == 0:
    ans = int(M/N)

elif M / N > 1000000:
    ans = 1

else:
    amax = M // N
    for i in range(amax, 0, -1):
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
if N==M:
  print(1)
else:
  a = 0
  for i in range(2,M):
    if M%i==0:
      a = i
  print(a)

Submission status: Wrong Answer

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

import itertools

def prime_factors(n):
    for i in itertools.chain([2], itertools.count(3, 2)):
        if n <= 1:
            break
        while n % i == 0:
            n //= i
            yield i

factors = list(prime_factors(M))
n = 1
for f in factors:
    if(f*n <= N):
        n = f*n
    else:
        break
print(n)

Submission status: Wrong Answer

Solution code:
mn = list(map(int, input().split()))
n = mn[0]
m = mn[1]

syou = m // n
amari = m // n
syou1 = syou

for i in range(syou):
    if amari == 0 or amari % syou1 == 0:
        break
    syou1 = syou1 - 1
    amari = amari + (n - 1)

print(syou1)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

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

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

p = list(set(prime_factorization(M)))

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

Submission status: Wrong Answer

Solution code:

lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2

while True:
    if M % i == 0:
        M = M // i
        lis.append(i)
    elif M == 1:
        break
    else:
        i += 1
ans = M_
ret = 1
for n in range(2**len(lis)):
    m = bin(n)[-1:1:-1]
    ret = 1
    for l in range(len(m)):
        if int(m[l]):
            ret *= lis[l]
            if  ret >= N:
                break
    if ret <=ans:
        ans = ret

print(M_//ans)

Submission status: Wrong Answer

Solution code:
import math
tmp=raw_input().split(" ")
N=int(tmp[0])
M=int(tmp[1])
i= 0
while i<=math.sqrt(M):
  if M%(N-i)==0:
    print(M/(N-i))
    break
  else:
  	i=i+1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if T % N == 0:
    print (int(T / N))
    exit()
    
while range(0,10):    
    A = int(T - N)
    #print(A)
#    T = int(N / A)
    if A <= 0:
        print(T)
        break
    T = A

Submission status: Wrong Answer

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

if M % N == 0:
    ans = int(M/N)

elif M / N > 10000000:
    ans = 1

else:
    amax = M // N
    for i in range(amax, 0, -1):
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

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

def solve():
    res = 1
    for i in range(2, m+1):
        if m % i == 0:
            if (m // i) >= n:
                res = max(res, i * (m // i // n))
                break
    print(res)

solve()

Submission status: Wrong Answer

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

if M % N == 0:
    print(int(M / N))
if (N % 2 == 1 & M % 2 == 0) | (N % 2 == 1 & M % 2 == 0):
    print(M % N)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
N,M=[int(i) for i in input().split()]
print(N,M)
m=3;list=[1];n=M
while m<=n:
    if n%m==0:
        list.append(m)
    m=m+1
    
print(list)
k = len(list)
for i in range(k):
    if N<list[i]:
        break

ans = int(M/list[i])
print(ans)

Submission status: Wrong Answer

Solution code:
mn = list(map(int, input().split()))
n = mn[0]
m = mn[1]

syou = m // n
amari = m // n
syou1 = syou

for i in range(syou):
    if amari == 0 or syou1 % amari == 0:
        break
    syou1 = syou1 - 1
    amari = amari + (n - 1)

print(syou1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())

def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

print(gcd(b%a,b//a))

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, int(M ** .5) + 1):
    p, q = divmod(M, i)
    if q == 0 and p >= N:
        ans = i
print(ans)

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.8)+10):
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
tmp=raw_input().split(" ")
N=int(tmp[0])
M=int(tmp[1])
i= 0
while i<=math.sqrt(M):
  if M%(N-i)==0:
    print(M%(N-i))
    break
  else:
  	i=i+1

Submission status: Wrong Answer

Solution code:
from sys import stdin

def partition():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    ans = 0
    if M % N == 0:
        ans = M // N
    else:
        a = (M // N)
        c = a - 1
        list = []
        list2 = []
        for i in range(1, a+1):
            if a % i == 0:
                list.append(i)
        list.reverse()
        b = M - (a * N)
        for x in list:
            if b % x == 0:
                ans = x
                break

        for i in range(1, c+1):
            if c % i == 0:
                list2.append(i)
        list2.reverse()
        d = M - (c * N)
        for x in list2:
            if d % x == 0:
                ans = max(ans, x)

    print(ans)



if __name__ == '__main__':
    partition()

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

result = []


def factorization(a):
    if a == 1:
        return
    for i in range(2, a + 1):
        if a % i == 0:
            result.append(i)
            factorization(int(a / i))
            return

#Mの素因数分解
factorization(M)
M_factors = result

#M_factorsの中で、N*αがM以下である最大となる因数αを算出
M_factors = [x for x in M_factors if N * x < M]

answer = 0


def search(M_factors, accept=[], reject=[]):
    global answer
    seki = 1
    for i in accept:
        seki *= i
    if N * seki > M:
        return
    if seki > answer:
        answer = seki
    if len(M_factors) == 0:
        return

    M_factors1 = M_factors.copy()
    M_factors2 = M_factors.copy()
    accept_ = accept.copy()
    reject_ = reject.copy()

    candidate = M_factors1.pop()
    accept_.append(candidate)
    search(M_factors1, accept_, reject)

    candidate = M_factors2.pop()
    reject_.append(candidate)
    search(M_factors2, accept, reject_)


search(M_factors)
print(answer)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
m= a[1]
yaku = []
flag = False
for i in range(1,m//2+1):
    if m % i == 0:
        yaku.append(i)
        if i >= n:
            print(int(m/i))
            flag = True
            break
if flag:
    aaa= 0
else:
    
    for i in yaku[::-1]:
        if int(m/i) >=n:
            print(i)
            break

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.7)+10):
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split(' '))

x = b//a

for i in range(x,0,-1):
        y =  b%a 
        if y%i ==0 :
            print(i)
            break

Submission status: Wrong Answer

Solution code:
from math import ceil
n, m = map(int, input().split())
for i in range(ceil(m/n), ceil(m**.5), -1):
    if not m % i:
        print(m//i)
        break
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,n+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
    print(x)

Submission status: Wrong Answer

Solution code:
A = input().split()
N = int(A[0])
M = int(A[1])

saidai =1



print(saidai)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
m= a[1]
yaku = []
for i in range(1,m//2+1):
    if m % i == 0:
        yaku.append(i)
        if i >= n:
            print(int(m/i))
            exit()
            break
            
for i in yaku[::-1]:
    if int(m/i) >=n:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def p_fact(n):
    res = dict()
    i = 2
    while i ** 2 <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res[i] = cnt
        i += 1
    if n > 0:
        res[n] = 1
    return res


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

if M % N == 0:
    print(M // N)
else:
    p = p_fact(M)
    N_max = M // N

    x = 1
    ans = 0
    for n in range(N, 0, -1):
        flg = True
        np = p_fact(n)
        for prim, cnt in p.items():
            if np.get(prim, 0) > cnt:
                flg= False
                break
            if flg:
                for n_prim, n_cnt in np.items():
                    if p.get(n_prim, 0) < n_cnt:
                        flg= False
                        break
        if flg:
            print(n)
            exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if M % N == 0:
    print(int(M / N))
else:
    print(M % N)

Submission status: Wrong Answer

Solution code:

lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2

while True:
    if M % i == 0:
        M = M // i
        lis.append(i)
    elif M == 1:
        break
    else:
        i += 1
ans = M_

for n in range(2**len(lis)):
    m = bin(n)[-1:1:-1]
    ret = 1
    for l in range(len(m)):
        if int(m[l]):
            ret *= lis[l]
            if  ret >= N:
                break
    if ret >= N and N <=ans:
        ans = ret

print(M_//ans)

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.5)+10):
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
print(int(b%a))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
import sys

N, M = map(int, input().split())
rootM = max(ceil(sqrt(M)), M//N) if M%N==0 else ceil(sqrt(M))

for m in reversed(range(1, rootM+1)):
    if M % m == 0:
        if M // m >= N:
            print(m)
            sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
else:
    if M % N == 0:
        ans = M // N
    for n in range(2, int(M ** 0.5) + 1):
        X = M - (n * N)
        if X % n == 0 and X >= 0:
            ans = max(ans, n)
        
        if M % n == 0 and n % N == 0:
            ans = max(ans, n, M // n)
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 21:37:39 2018

@author: ogura
"""
import math
import fractions

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

for i in range(100000):
    a = fractions.gcd(m, i)
    if a == 1:
        continue
    tmp = int(a *(1 - a ** n) // (1 - a))
    if tmp == m:
        break

print(a)

Submission status: Wrong Answer

Solution code:
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append(b)
        b, e = b + 1, 0
    if n > 1:
        fct.append(n)
    fct.sort()
    fct.reverse()
    return fct

n, m = list(map(int, input().split()))
f = factorize(m)
for x in f:
    if x * n <= m:
        print(x)
        exit()

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 0
    for i in range(1, int(m**0.5)+10):
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split(" ")]

maxable = M // N
while True:
    res = maxable * N
    diff = M - res
    if not diff:
        print(maxable)
        break
    elif diff % maxable == 0:
        print(maxable)
        break
    maxable //= 2

Submission status: Wrong Answer

Solution code:
from sys import stdin


def EuclideanAlgorithm(a, b):
    if (a < b):
        a, b = b, a

    if b > 0:
        return EuclideanAlgorithm(b, a % b)
    else:
        return a


N, M = [int(a) for a in stdin.readline().rstrip().split()]

ans = 1
if M % N == 0:
    ans = M // N
else:
    s = M // N
    r = M % N

    for i in range(1, r + 1):
        if r % i != 0:
            continue
        else:
            r_divided = r // i
            tmp = EuclideanAlgorithm(s + r_divided, s)
            if tmp > ans:
                ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
m= a[1]
yaku = []
for i in range(n,m//2+1):
    if m % i == 0:
        yaku.append(i)
        if i >= n:
            print(int(m/i))
            break
for i in yaku[::-1]:
    if int(m/i) >=n:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    n, m = map(int, input().split())
    ans = 0
    for i in range(1, int(m**0.5)):
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    else:
        return a if b == 0 else gcd(b, a % b)

if M % N == 0:
    print(M//N)
else:
    mod = M % N
    b = M //N
    r = gcd(b, mod)
    print(r)

Submission status: Wrong Answer

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

# j = M
# I=int(j)
# s=0
# R=int(I)
# L=[]

# while s==0:
#     for i in range(2,R+1):
#         if I%i==0:
#             I=I/i
#             if I==1:
#                 s=1
#             L.append(i)
#             break
# print(L)
# ans = 1
# for l in L:
#     if l >= N:
#         ans = max(M//l,ans)

i = 1
ans = 0
tmp = 1000000000

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

while M//i >= i and N > i and i <= tmp:
    if M%i == 0:
        if tmp == 1000000000:
            tmp = M//i
        if M//i >= N:
            ans = max(ans,i)
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(int(m**.5), int(m/n)):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
else:
    if M % N == 0:
        ans = M // N
    for n in range(2, int(M ** 0.5) + 1):
        X = M - (n * N)
        if X % n == 0 and X >= 0:
            ans = max(ans, n)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2

while True:
    if M % i == 0:
        M = M // i
        lis.append(i)
    elif M == 1:
        break
    else:
        i += 1
ans = M_

print(lis)
for n in range(2**len(lis)):
    m = bin(n)[-1:1:-1]
    ret = 1
   # print(m)
    for l in range(len(m)):
        if int(m[l]):
            ret *= lis[l]
           # print(lis[l])
            if  ret > N:
                break
    if ret >= N:
        #print(ret)
        ans = min(ans,ret)

print(M_//ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
elif M % N == 0:
    print(M // N)
else:
    for n in range(2, int(M ** 0.5) + 1):
        X = M - (n * N)
        if X % n == 0 and X >= 0:
            ans = n
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split());print(M%(M//N))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
for i in range(2, int(M ** .5) + 1):
    p, q = divmod(M, i)
    if q == 0 and p >= N:
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=input().split()
N=int(N)
M=int(M)
L=[]
i=2
while True:
    if M==1:
        break
    elif M%i==0:
        M=M/i
        L.append(i)
    else:
        i+=1
    
result=1
for p in L:
    if p>N:
        for p2 in L:
            result=result*p2
        print(int(result/p))
        break

Submission status: Wrong Answer

Solution code:
a=[]
b=0
n,m=map(int,input().split(" "))
for i in range(2,n+1):
    if m%i==0:
        a.append(i)
for i1 in a:
    if m/i1 >=n:
        b=i1
if a==[]:
    print(1)
else:
    print(b)

Submission status: Wrong Answer

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

values = []
for i in range(1, 1000000):
    if m % i == 0 and m / i >= n:
        values.append(i)
print(max(values))

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
q, r = divmod(M, N)

if r == 0:
    print(q)
else:
    cand = 1
    for p in range(1, int(math.sqrt(q)) + 1):
        if q % p == 0 and  r % p == 0:
            cand = p
    print(cand)

Submission status: Wrong Answer

Solution code:
from math import floor, ceil
N, M = [int(elem) for elem in input().split(' ')]

max_gcd = 1
upperbound = M // N
cand = M // N

if M % N == 0:
    print(cand)
    exit(0)
else:
    coef = 1
    rest = M - upperbound * N
    while (cand > 1):
        num_moving = (coef * upperbound - rest) // (N + coef)
        cand = upperbound - num_moving
        if (num_moving * N + rest) % cand == 0:
            print(cand)
            exit(0)
        else:
            coef += 1

Submission status: Wrong Answer

Solution code:
from sys import stdin


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


N, M = [int(a) for a in stdin.readline().rstrip().split()]

ans = 1
if M % N == 0:
    ans = M // N
else:
    s = M // N
    r = M % N

    for i in range(1, r + 1):
        if r % i != 0:
            continue
        else:
            r_divided = r // i
            tmp = gcd(s + r_divided, s)
            if tmp > ans:
                ans = tmp

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(int(m/n), int(n**.5), -1):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), n**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
s=M//N
L=math.sqrt(M)
l=math.floor(L)
a=[]
for i in range(1,l+2):
    d=M/i 
    if d.is_integer()==True:
        a.append(i)
        a.append(d)
b=list(filter(lambda x:x<=s, a))
c=max(b)
print(c)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
s = 0
arr = []
if m % n == 0:
	ans = m / n
	print(int(ans))
else:
	for i in range(1, m // 2 + 1):
		if m % i == 0:
			arr.append(i)
	for num in arr:
		if num * n >= m:
			arr.remove(num)
	print(max(arr))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
flag=0
if m %n ==0:
    flag=1
    print(m//n)
else:
    jops=1
    I = m
    s = 0
    R = int(I)
    while s == 0:
        #R=int(math.sqrt(R))
        for i in range(2, R+1):
            if I % i == 0:
                I = I/i
                jops*=i
                if m//jops > n-1:
                    print(jops)
                    s=1
                    flag=1
                    break
                elif I == 1:
                    s = 1
                    break
    if flag==0:
        print(1)

Submission status: Wrong Answer

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

# j = M
# I=int(j)
# s=0
# R=int(I)
# L=[]

# while s==0:
#     for i in range(2,R+1):
#         if I%i==0:
#             I=I/i
#             if I==1:
#                 s=1
#             L.append(i)
#             break
# print(L)
# ans = 1
# for l in L:
#     if l >= N:
#         ans = max(M//l,ans)

i = 1
ans = 0

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

while M//i >= i and N > i:
    if M%i == 0:
        if M//i >= N:
            ans = max(ans,i)
    i += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if M % N == 0:
    print(M//N)
else:
    print(fractions.gcd((M // N), (M % N)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

        if M % n == 0:
            ans = n
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
s=M//N
L=math.sqrt(M)
l=math.floor(L)
a=[]
for i in range(1,l+1):
    d=M/i 
    if d.is_integer()==True:
        a.append(i)
        a.append(d)
b=list(filter(lambda x:x<=s, a))
c=max(b)
print(c)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,n+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
        if m%i==0 and (m//i)*n<=m:
            x=max(x,m//i)
    print(x)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if (m > 1e8) and (m%1000==0):
    max_itr = m//n
    for i in range(max_itr, 0, -100):
        if m%round(i, -2)==0:
            break
    print(round(i, -2))
else:
    max_itr = m//n
    for i in range(max_itr, 0, -1):
        if m%i==0:
            break
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if M % N == 0:
    print(int(M/N))
else:
    print(M - (int(M/N) * N))

Submission status: Wrong Answer

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

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1] % i == 0 and i <= b:
        c.append(i)
c.reverse()
for i in c:
    if a[1] % i == 0:
        print(i)
        break

Submission status: Wrong Answer

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

mp = m % n

if mp == 0:
    print(m//n)
    exit()
i = 1
while 1:
    if mp % i == 0:
        a = mp/i
        # aを小さくして行く
        if (m // n)% a == 0:
           print(int(a))
           exit()
    i += 1

Submission status: Wrong Answer

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

# j = M
# I=int(j)
# s=0
# R=int(I)
# L=[]

# while s==0:
#     for i in range(2,R+1):
#         if I%i==0:
#             I=I/i
#             if I==1:
#                 s=1
#             L.append(i)
#             break
# print(L)
# ans = 1
# for l in L:
#     if l >= N:
#         ans = max(M//l,ans)

i = 1
ans = 0

if M%N == 0:
    ans = max(ans,M//N)

while M//N//i >= i:
    if M%i == 0:
        if M//i >= N:
            ans = max(ans,i)
    i += 1

print(ans)

Submission status: Wrong Answer

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

if m %n ==0:
    flag=1
    print(m//n)
else:
    jops=1
    I = m
    s = 0
    R = int(I)
    L = []
    flag=0
    while s == 0:
        #R=int(math.sqrt(R))
        for i in range(2, R+1):
            if I % i == 0:
                I = I/i
                jops*=i
                if m//jops > n:
                    print(jops)
                    s=1
                    flag=1
                    break
                if I == 1:
                    s = 1
                L.append(i)
                break
    if flag==0:
        print(1)

Submission status: Wrong Answer

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1