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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
for i in range(m // n, 1, -1):
    if m % i == 0:
        print(i)
        exit()

Submission status: Wrong Answer

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

if N < M/2:
    for i in range(N,M+1):
        if M % i == 0:
            ans = int(M/i)
            break
else:
    for i in range(N):
        if M % (N-i)==0:
            ans = int(M/(N-i))
            break

print(ans)

Submission status: Wrong Answer

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

ans_max = M//N
ans = 0

for i in range(N,M):
    if M % i == 0:
        ans = int(M/i)
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
# また答えが見つかってなければTrue
flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(8):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split(' '))
l = [0]
for i in range(1,int(pow(M,0.5)+2)):
    if M%i==0:
        l.append(i)
        l.append(M//i)
if len(l)==1:
    print(0)
    exit()
l = sorted(list(set(l)))
for n,i in enumerate(l[1:]):
    if M/i<N:
        print(l[n])
        break

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split(' '))
l = [0]
for i in range(1,int(pow(M,0.5)+2)):
    if M%i==0:
        l.append(i)
        l.append(M//i)
if len(l)==1:
    print(0)
    exit()
l = sorted(l)
for n,i in enumerate(l[1:]):
    if M/i<N:
        print(l[n])
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    divisors = set(calcDivisor(M))
    mx = 0
    for d in divisors:
        if N * d > M:
            continue
        mx = max(mx,d)
    print(mx)

def calcDivisor(n):
    res = []
    for i in range(1, int(math.sqrt(n)+1)):
        if n % i == 0:
            res.append(i)
    return res

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import math

divisor=[]
for i in range(1, math.ceil(math.sqrt(M))+1):
    if M%i==0:
        divisor.append(i)
#print(divisor)

divisor=list(reversed(divisor))
for val in divisor:
    if M//val>=N:
        print(val)
        break

Submission status: Wrong Answer

Solution code:
import math


def divisor(x):
    d = [1]
    for i in range(2, math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d.append(i)
    if d[-1] != x:
        d.append(x)
    return d
    


def submit():
    n, m = map(int, input().split())

    # Mの約数を求める
    d = divisor(m)
    nd = len(d)

    d_max = 0
    for i in range(nd):
        if d[i] * n <= m:
            d_max = d[i]
    print(d_max)
    

submit()

Submission status: Wrong Answer

Solution code:

import math


def divisor(x):
    d = [1]
    for i in range(2, math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d.append(i)
    if d[-1] != x:
        d.append(x)
    return d
    


def submit():
    n, m = map(int, input().split())

    # Mの約数を求める
    d = divisor(m)
    nd = len(d)

    # 二分探索で条件を満たすdを求める
    l = 0
    r = nd - 1
    while l <= r:
        mid = (l + r) // 2
        if n * d[mid] <= m:
            l = mid + 1
        else:
            r = mid - 1
    print(d[l - 1])


submit()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = m-((m//n)*n)
if ans != 0:
    print(ans)
else:
    print(m//n)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

divisor_set=set()
for i in range(1,int(math.sqrt(M+1))):
  if M%i==0:
    divisor_set.add(i)
    divisor_set.add(M//i)
#print(divisor_set)

divisor_list=list(divisor_set)
divisor_list.sort()

for l in divisor_list:
  if l>=N:
    answer=M//l
    print(answer)
    break

Submission status: Wrong Answer

Solution code:
import sys
import math

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

divisor_set=set()
for i in range(1,int(math.sqrt(M))):
  if M%i==0:
    divisor_set.add(i)
    divisor_set.add(M//i)
#print(divisor_set)

divisor_list=list(divisor_set)
divisor_list.sort()

for l in divisor_list:
  if l>=N:
    answer=M//l
    print(answer)
    break

Submission status: Wrong Answer

Solution code:
import sys
import math

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

divisor_set=set()
for i in range(1,int(math.sqrt(M))):
  if M%i==0:
    divisor_set.add(i)
    divisor_set.add(M//i)
#print(divisor_set)

answer=0
for s in divisor_set:
  if s>=N:
    answer=max(answer,M//s)
    
print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
m_root=int(m**0.5)
div_l=[]
ans=0

for i in range(1,m_root + 1):
    if m%i == 0:
        div_l.append(i)
        div_l.append(m//i)

if n//m in div_l:
    ans = m//n
else:
    div_l.append(m//n)
    div_l.sort()
    ans = div_l[div_l.index(m//n) - 1]
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
m_root=int(m**0.5)
ans=0

if m%n==0:
    ans=m//n
else:
    for i in range(1,m_root +1):
        if m%i == 0:
            if i < m//n:
                ans = max(ans,i)
            else:
                ans = max(ans, m//i)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
m_root=int(m**0.5)
ans=0

if m%n==0:
	ans=m//n
for i in range(1,m_root +1):
	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())
m_root = int(m**0.5)
ans=0
for i in range(1,m_root+1):
	if m%i == 0 and m/i >= n:
		ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
ans = fractions.gcd(M//N,(M//N)+M%N)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
        if(N//i!=i):
            arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
k = m//n
ans = 1
i = 1
while i**2 <= m:
	if m%i==0:
		j = m/i
		if j <= k:
			print(j);exit()
		if i <= k:
			ans = max(ans,i)
	i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
i = 1
lis = []
while M//i>=N and i<=M**0.5:
  if M % i == 0:
    lis.append(i)
  i += 1
print(lis[-1])

Submission status: Wrong Answer

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

# Mの約数を列挙
sup = int(M**0.5) + 1
divs = []
for i in range(1, sup+1):
  if M%i == 0:
    divs.append(i)

for d in divs[::-1]:
  if M//d >= N:
    print(d)
    quit()

Submission status: Wrong Answer

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

i=1
ans=0

while i*i<=m:
    if m%i==0:
        if n<=m/i:
            ans=max(ans,i)
        if n<=i:
            ans=max(ans,m/i)
        
    i+=1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n, m = map(int, input().split())
  divisors = []
  
  for i in list(range(1, floor(m**0.5)+1)):
    if m%i == 0:
      divisors.append(i)    
  if m//divisors[-1] > floor(m**0.5):
    divisors.append(m//divisors[-1])
  divisors.append(m)
  
  for divisor in divisors[::-1]:
    if m//divisor >= n:
      print(divisor)
      return
    
if __name__=='__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
# 素因数分解して N より大きい数になるまで積をかけた時、残りの数の積が答え
# 素因数分解して N より大きい数になるまで積をかけた時 -> つまり 約数
# Mの約数でNより小さいものの中で最大
ans = 0
for i in range(1, M):
    if i * i > M:
        break
    if i > N:
        break
    if M % i == 0:
        ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

Solution code:
# これはエスパーですが、
# 1. 最大公約数の最大化なので1とか2とかは避けないと駄目
# 2. N個の数でMを構成するので、↑から、できるだけ小さい数を避けて大きい数を揃えたいが、どれかを大きくするとどれかが小さくなってしまう
#   -> 均等にわける （M/N）
# 余ったやつを適当にどれかに足す。なので数列を構成する数値は2種類だけになる
# （よくよく考えたら種類が多いとそのぶんgcdが小さくなりそうなのでこれでよさそう）
# ex): n, m = 5, 10 -> (2, 2, 2, 2, 2)で2
# ex): n, m = 4, 10 -> (2, 2, 2, 4)で2
# ex): n, m = 5, 13 -> (2, 2, 2, 2, 5)で1
n, m = map(int, input().split())
a, b = m // n, m // n + m % n


def gcd(a, b):
    if a > b:
        return gcd(b, a)
    while a != 0:
        a, b = b % a, a
    return b


print(gcd(a, b))

Submission status: Wrong Answer

Solution code:
# import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
# ind=bisect.bisect_left(enum,m//n)
# if(enum[ind]==m//n):
#     print(enum[ind])
# elif(ind==0):
#     print(enum[ind])
# else:
#     print(enum[ind-1])
ans=1
for i in range(len(enum)):
    if(enum[i]>m/n):
        break
    ans=max(enum[i],ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
# ind=bisect.bisect_left(enum,m//n)
# if(enum[ind]==m//n):
#     print(enum[ind])
# elif(ind==0):
#     print(enum[ind])
# else:
#     print(enum[ind-1])
ans=1
for i in range(len(enum)):
    if(enum[i]>m/n):break
    ans=enum[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
# ind=bisect.bisect_left(enum,m//n)
# if(enum[ind]==m//n):
#     print(enum[ind])
# elif(ind==0):
#     print(enum[ind])
# else:
#     print(enum[ind-1])
ans=1
for i in range(len(enum)):
    if(enum[i]>m//n):break
    ans=enum[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int,input().split())
def enum_dif(n):
    ret=[]
    i=1
    while i*i<=n:
        if(n%i==0):
            ret.append(i);
            if(i!=1 and i*i != n):
                ret.append(n//i)
        i+=1
    return ret
enum=enum_dif(m)
enum.sort()
# print(enum)
# ind=bisect.bisect_left(enum,m//n)
# if(enum[ind]==m//n):
#     print(enum[ind])
# elif(ind==0):
#     print(enum[ind])
# else:
#     print(enum[ind-1])
ans=0
for i in range(len(enum)):
    if(enum[i]>m//n):break
    ans=enum[i]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 1
a = []
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        x = m // i
        if x >= n:
            a.append(i)
        if i >= x:
            a.append(x)

print(max(a))

Submission status: Wrong Answer

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

cnt = 1
a = []
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        x = m // i
        if x >= n:
            a.append(i)

print(max(a))

Submission status: Wrong Answer

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

cnt = 1
for i in range(int(m ** 0.5) + 1,0,-1):
    # print(i,m/i)
    if m % i == 0:
        if m // i >= n:
            cnt = m // i
            break
print(m//cnt)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
ans = 1
for d in range(1, int(M**0.5)+1):
    if M % d == 0 and d <= M / N:
        ans = max(ans, d)
        if M // d <= M // N:
            ans = max(ans, d)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
ans = 1
for d in range(1, int(M**0.5)+1):
    if M % d == 0 and d <= M / N:
        ans = max(ans, d)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
ans = -1
for d in range(1, int(M**0.5)+1):
    if M % d == 0 and d <= M / N:
        ans = max(ans, d)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
ans = -1
for d in range(1, int(M**0.5)+1):
    if M % d == 0 and d <= M / N:
        ans = d
print(ans)

Submission status: Wrong Answer

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

a = (m//n)+1

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

Submission status: Wrong Answer

Solution code:
def pin(type=int):
    return map(type,input().split())
N,M=pin()
t=M//N
#Mを因数分解する必要など無いか…？
#print(t)
for p in reversed(range(2,t+1)):
    if M%p==0:
        print(p)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    if i<=num and ans<i:
        ans=i

print(ans)

Submission status: Wrong Answer

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

num=m//n
ans=1
for i in range(int(m**0.5),2,-1):
    Num=i
    if m%i==0:
        Num1=m//i if m//i<=num else 1
        if Num>num:
            Num=1

        ans=max(ans,Num,Num1)

print(ans)

Submission status: Wrong Answer

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

num=m//n
ans=0
for i in range(int(m**0.5),1,-1):
    Num=i
    if m%i==0:
        Num1=m//i if m//i<=num else 0
        if Num>num:
            Num=0

        ans=max(ans,Num,Num1)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N, M = map(int, input().split())
i = 2
res = 1
while i * i <= M:
  t = 1
  if M % i == 0 and (M // i >= N):
    res = max(res, i)
    t = M // i
  if M % t == 0 and (M // t >= N):
    res = max(res, t)
  i += 1
print(res)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N, M = map(int, input().split())
i = 2
k = M + 0
ps = []
while i * i <= M:
  while M % i == 0:
    ps.append(i)
    M //= i
  i += 1
if M > 1: ps.append(M)
res = 0
for i in range(len(ps)):
  for c in combi(ps, i):
    t = 1
    for x in c: t *= x
    if N <= t: res = max(res, k // t)
print(res)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

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

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

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

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    maxGCD = 1
    for gcd in range(2, M):
        if gcd * gcd > M: break
        else:
            if M % gcd == 0:
                other = M // gcd
                if gcd >= N: maxGCD = max(other, maxGCD)
                if other >= N: maxGCD = max(gcd, maxGCD)
    print(maxGCD)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    maxGCD = 1
    for gcd in range(2, M):
        if gcd * gcd > M: break
        else:
            if M % gcd == 0:
                if M // gcd >= N: maxGCD = gcd
    print(maxGCD)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

ans = 1
for num, cnt in div:
    if cnt >= N:
        ans = max(ans, num)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    for i in range(1,min(int(m**0.5)+2,m//n+1)):
        if m%i==0:
            ans=i
    print(ans)     
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    for i in range(1,min(int(m**0.5)+2,(m+n-1)//n+1)):
        if m%i==0:
          ans=i
    print(ans)     
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

for i in reversed(range(10 ** 5 + 1)):
    x = m - n * i
    if x >= 0 and x % i == 0:
        print(i)
        break

Submission status: Wrong Answer

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

for i in reversed(range(n + 1)):
    x = m - n * i
    if x >= 0 and x % i == 0:
        print(i)
        break

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
lol=[1]
a=1
k=pow(y,0.5)
for i in range(2,int(k)+1):
    if y%i==0:
        if i*x<=y:
            a=max(a,i)
        if (y//i)*x<=y:
            a=max(a,i)
print(a)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
lol=[1]
a=0
k=pow(y,0.5)
for i in range(2,int(k)+1):
    if y%i==0:
        if i*x<=y:
            a=max(a,i)
        if (y//i)*x<=y:
            a=max(a,i)
print(a)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    for i in range(m_div, 1, -1):
        if M % i == 0 and M // i >= N:
            print(i)
            exit()
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    m_sqrt = int(math.sqrt(M)) + 2

    for i in range(m_sqrt, 1, -1):
        if M % i == 0 and M // i >= N:
            print(i)
            exit()
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


N, M = map(int, input().split())
rest = M - M // N * (N - 1)
if rest > M // N:
    print(gcd(rest, M // N))
else:
    print(gcd(M // N, rest))

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行ありl
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M >= (M//i)*N:
        ans = M//i
        break

    if M % i == 0:
        ans = i



print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M % i == 0:
        ans = i



print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, int(math.sqrt(M) + 100)):

    if (M - i*N) % i == 0 and M >= i*N:
        ans = i



print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


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

ans = 0
for i in range(1, int(math.sqrt(M) + 1)):

    if (M - i*N) % i == 0 and M >= i*N:
        ans = i



print(ans)

Submission status: Wrong Answer

Solution code:
def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
print(l)
for i in l:
 if m/n>=i:
  print(i)
  exit()

Submission status: Wrong Answer

Solution code:
N,M = [int(i) for i in input().split()]
if M % N == 0:
    print(M//N)
    exit()
else:
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    li = factorization(M)
    n = len(li)
    ans = 1
    for i in range(n):
        if M // li[i][0] >= N:
            if ans < li[i][0]:
                ans = li[i][0]
    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,5*10**6)):
 chk=m-(i*n)
 if chk>=0 and chk%i==0:
  ans=i
print(ans)

Submission status: Wrong Answer

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

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

for i in range(n,0,-1):
 chk=m-(i*n)
 if chk>=0 and chk%i==0:
  print(i)
  exit()
print(1)

Submission status: Wrong Answer

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

for i in range(n,0,-1):
 chk=m-(i*n)
 if chk>=0 and chk%i==0:
  print(i)
  exit()
print(1)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = (int(i) for i in input().split())
    c = M // N
    r = M % N
    if r == 0:
        return print(c)

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x
    print(gcd(c, c+r))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if m % n == 0:
    ans = m // n
    print(ans)
    exit()
ans = 1
m -= n
while m - n > 0:
    m -= n
    ans += 1
    if m % ans == 0:
        if (m // ans) % n == 0:
            ans += (m // ans) // n
        print(ans)
        exit()
print(ans)

Submission status: Wrong Answer

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

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

ans = 1

for a in range(1, int(math.sqrt(M))+1):
  if M % a != 0:
    continue

  if a * N <= M:
    ans = max(ans, a)

print(ans)

Submission status: Wrong Answer

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

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

ans = 1

for n in range(1, int(math.sqrt(M))+1):
  base = n * (N - 1)
  if M - base < n:
    break

  if (M - base) % n == 0:
    ans = max(ans, n)

print(ans)

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()

  if n==1:
    return m

  a=0
  for i in range(2,int(math.sqrt(m))+1):
    if m%i==0:
      if m>=i*n:
        a=max(a,i)
      if m>=m//i*n:
        a=max(a,m//i)

  return a

# main()
print(main())