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:
from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
for g in range(1,floor(sqrt(M))+1):
    if M%g == 0:
        x = M//g
        if x > floor(sqrt(M)) and g >= N:
            ans = x
        if x >= N:
            ans = g
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
for g in range(1,floor(sqrt(M)+1)):
    if M%g == 0:
        x = M//g
        if x > floor(sqrt(M)) and g >= N:
            ans = x
        if x >= N:
            ans = g
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
n = N
for g in range(1,floor(sqrt(M)+1)):
    if M%g == 0:
        x = M//g
        if x > floor(sqrt(N)) and g >= N:
            ans = x
        if x >= N:
            ans = g
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    # if i >= n:
    #     ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    # if j >= n:
    #     ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
# N以上でMを割り切ることができる最小の数nを求める　→ 答え M//n
N, M = MAP()

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

divisors = make_divisors(M)
print(divisors)
n = divisors[bisect_left(divisors, N)]
print(M//n)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        sys.exit()
    r = 1
    #for i1 in range(2, ceil(sqrt(m))+1):
    for i1 in range(2, m + 1):
        if m % i1 == 0:
            r = i1
        if n * i1 > m:
            break
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        sys.exit()
    r = 1
    for i1 in range(2, ceil(sqrt(m))+1):
        if m % i1 == 0:
            r = i1
        if n * i1 > m:
            break
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        r = 1
        for i1 in range(2, ceil(sqrt(m))+1):
            if m % i1 == 0:
                r = i1
        print(r)
        sys.exit()
    r = 1
    for i1 in range(2, ceil(sqrt(m))+1):
        if m % i1 == 0:
            r = i1
        if n * i1 > m:
            break
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
K = M//N
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        if i <= K:
            ans = max(ans, i)
        if M//i <= K:
            ans = max(ans, i)

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N, M = map(int, input().split())
for i in range(min(int(M**0.5)+1, M//N), 0, -1):
    if M%i == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N, M = map(int, input().split())
m = M

ans = 1
d = []

while M%2 == 0:
    d.append(2)
    M //= 2
for i in range(3, int(M**0.5)+1, 2):
    while M%i == 0:
        d.append(i)
        M //= i
    if M == 1:
        break
if M > 1:
    d.append(M)
for i in range(1, len(d)+1):
    S = combinations(d, i)
    for num in S:
        temp = 1
        for t in num:
            temp *= t
            if temp >= N:
                ans = max(ans, m//temp)
                break

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N, M = map(int, input().split())
m = M

ans = 1
d = []
minn = M

while M%2 == 0:
    d += [2]
    M //= 2
for i in range(3, int(M**0.5)+1, 2):
    while M%i == 0:
        d += [i]
        M //= i
    if M == 1:
        break
for i in range(1, len(d)+1):
    S = combinations(d, i)
    for num in S:
        temp = 1
        for t in num:
            temp *= t
            if temp >= N:
                ans = max(ans, m//temp)
                break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  l = []
  for i in range(1,int(a**0.5)+1):
    if m%i==0:
      l.append(i)
      if m//i<=a:
        l.append(m//i)
  l = sorted(l)[::-1]
  if len(l)!=0:
    print(l[0])
  else:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  l = []
  for i in range(1,int(a**0.5)+1):
    if m%i==0:
      l.append(i)
      l.append(m//i)
  l = sorted(l)[::-1]
  for i in l:
    if i<=a:
      s = m-n*i
      if s%i==0:
        print(i)
        exit()
print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  l = []
  for i in range(1,int(a**0.5)+1):
    if m%i==0:
      l.append(i)
      l.append(m//i)
  l = sorted(l)[::-1]
  for i in l:
    if i<a:
      s = m-n*i
      if s%i==0:
        print(i)
        exit()
print(1)

Submission status: Wrong Answer

Solution code:

n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  for i in range(a,0,-1):
    s = m-n*i
    if (s+i)%i==0:
      print(i)
      exit()
    elif a>10**6 and i == a-10**6:
      print(1)
      exit()

Submission status: Wrong Answer

Solution code:
import copy
def cd_generator(num):
    ans=[]
    for i in range(2,10000000):
        if num%i==0:
            ans.append(i)
    temp=copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num//ele)
    return ans
def main():
    n,m=map(int,input().split())
    array=cd_generator(m)
    ans=0
    for ele in array:
        if m//ele>=n:
            ans=max(ans,ele)
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import copy
def cd_generator(num):
    ans=[]
    for i in range(2,1000000):
        if num%i==0:
            ans.append(i)
    temp=copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num//ele)
    return ans
def main():
    n,m=map(int,input().split())
    array=cd_generator(m)
    ans=0
    for ele in array:
        if m//ele>=n:
            ans=max(ans,ele)
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import copy
def cd_generator(num):
    ans=[]
    for i in range(2,60000):
        if num%i==0:
            ans.append(i)
    temp=copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num//ele)
    return ans
def main():
    n,m=map(int,input().split())
    array=cd_generator(m)
    ans=0
    for ele in array:
        if m//ele>=n:
            ans=max(ans,ele)
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import copy
def cd_generator(num):
    ans=[]
    for i in range(2,4*10**4):
        if num%i==0:
            ans.append(i)
    temp=copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num//ele)
    return ans
def main():
    n,m=map(int,input().split())
    array=cd_generator(m)
    ans=0
    for ele in array:
        if m/ele>=n:
            ans=max(ans,ele)
    print(ans)
main()

Submission status: Wrong Answer

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

ans = 0
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:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()

    ans = 1
    inf = 10**4 + 5
    for i in range(2, inf):
        if i * N <= M and M % i == 0:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd


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

Submission status: Wrong Answer

Solution code:
import math
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N,M=map(int,input().split())
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if N==1:
  print(M)
else:
  ans=0
  a=M//N
  v=make_divisors(M)
  for i in range(a,0,-1):
    if M%i==0:
      b=i
      break
  p=max(b,a)
  q=min(b,a)
  print(gcd(p,q))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

N,M=map(int,input().split())
if N==1:
  print(M)
else:
  ans=0
  a=M//N
  for i in range(int(math.sqrt(M)),0,-1):
    if M%i==0 and a>=i:
      ans=max(ans,gcd(i,a))
      break
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if N==1:
  print(M)
else:
  a=M//N
  print(gcd(a,M%N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m)+1)):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m))):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

def mdiv(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:

            divisors.append(i)
            if i!=n//i:
                if n//i<=m/n:
                    divisors.append(n//i)
    return divisors
#print(mdiv(m))

ans=0
for i in mdiv(m):
    if i<=m//n:
        ans=max(i,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

def mdiv(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:

            divisors.append(i)
            if i!=n//i:
                if n//i<=m/n:
                    divisors.append(n//i)
    return divisors
#print(mdiv(m))
p=max(mdiv(m))
ans=p
for i in range(p,m//n +1,p):
    if m%i==0:
        ans=max(i,p)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

from fractions import gcd
from functools import reduce

#list
def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list([m//n,m//n+(m%n)]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

from fractions import gcd
from functools import reduce

#list
def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list([m//n,m%n]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
from fractions import gcd
from functools import reduce
from pprint import pprint
# from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = MI()

q = m//n
r = m%n

l = [q]*(n-1)
l.append(q+r)

def gcd3_list(numbers):
    return reduce(gcd, numbers)

ans = gcd3_list(l)
print(ans)

Submission status: Wrong Answer

Solution code:
def __gcd__(m,n):
    x,y=max(m,n),min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x,y=y,z
        else:
            return z
        
from functools import reduce
def GCD(*X):
    return reduce(__gcd__,X)

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

Q=M//N
R=M%N

if R==0:
    print(Q)
else:
    print(GCD(Q,R))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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


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

div = make_divisors(num=m)
div.sort()
ans = 0
for x in div:
    if x*n <= m:
        ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

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

def factorization(n):
    factor_list = []
    if n <= 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(2, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)

    return factor_list

factor = factorization(M)
factor.sort()

ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

Submission status: Wrong Answer

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

def factorization(n):
    factor_list = []
    if n <= 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(2, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)

    return factor_list

factor = factorization(M)
factor.sort()
print(factor)
ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

Submission status: Wrong Answer

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

def factorization(n):
    factor_list = []
    if n <= 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(2, limit):
        if n % i == 0:
            factor_list.append(i)
            factor_list.append(n//i)

    return factor_list

factor = factorization(M)

ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
    a = m%n
    b = m//n
    c = a+b
    while True:
        if gcd(b,c)!=1:
            print(gcd(b,c))
            exit()
        else:
            c -= 1
print(1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(input())
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        if N * i <= M: ans = max(ans, i)
        if N * (M // i) <= M: ans = max(ans, i)
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(input())
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5)+1)):
        if M % i: continue
        if N * i <= M: ans = max(ans, i)
        if N * (M // i) <= M: ans = max(ans, i)
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if M==1: print(1);exit()
if N==1: print(M); exit()
ans = 1
for i in range(2,int(M**(1/2)+2)):
    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 M==1: print(1);exit()
if N==1: print(M); exit()
ans = 1
for i in range(2,int(M**(1/2)+2)):
    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 M==1: print(1);exit()
if N==1: print(M); exit()
ans = 1
for i in range(2,min(int(M**(1/2))+2,int(M/N)+1)):
    if M%i==0: ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())

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

#     upper_divisors.reverse()
#     return lower_divisors + upper_divisors


# こっちだとどうなる？
def make_divisors(x):
    ret = []
    i = 1
    while i * i <= x:
        if x % i == 0:
            ret.append(i)
            # 最初と最後が重複しないか確認
            if i != 1 and i * i != x:
                ret.append(x // i)
        i += 1
    return ret


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    divisors = make_divisors(m)[::-1]
    for d in divisors:
        if d <= x:
            print(d)
            exit()

Submission status: Wrong Answer

Solution code:
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    for i in range(int(x**0.5), 0, -1):
        if m % i == 0:
            print(i)
            exit()
print(1)