Problem:


Score : 200 points

Problem Statement

You are given positive integers A and B.

Find the K-th largest positive integer that divides both A and B.

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

1 \leq A, B \leq 100

The K-th largest positive integer that divides both A and B exists.

K \geq 1

Input

Input is given from Standard Input in the following format:

A B K

Output

Print the K-th largest positive integer that divides both A and B.

Sample Input 1

8 12 2

Sample Output 1

2

Three positive integers divides both 8 and 12: 1, 2 and 4.
Among them, the second largest is 2.

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1



Sample input:
8 12 2


Sample output:
2

Submission status: Accepted

Solution code:
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    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

    a,b,k = map(int,input().split())
    a_list = make_divisors(a)
    b_list = make_divisors(b)

    ans = []
    for i in range(len(a_list)):
        if a_list[i] in b_list:
            ans.append(a_list[i])

    ans.reverse()
    print(ans[k-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

target = list()

for i in range(1, max(a,b)+1):
  if a%i==0 and b%i==0:
    target.append(i)

print(target[-k])

Submission status: Accepted

Solution code:
import fractions

A,B,K=map(int,input().split())
gcd=fractions.gcd(A,B)
#print(gcd)
l=[]
for i in range(1,gcd+1):
    if gcd%i==0:
        l.append(i)
#print(l)
print(l[len(l)-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
li = []
for i in range(1, min(A, B) + 1) :
    if A % i == 0 and B % i == 0 :
        li.append(i)
li.sort(reverse=True)
print(li[K - 1])

Submission status: Accepted

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

ans=[]

for i in range(1,max(a,b)+1):
  if a%i ==0 and b%i ==0:
    ans.append(i)

    
ans.sort(reverse=True)
print(ans[k-1])

Submission status: Accepted

Solution code:
def main():
    a,b,k = map(int,input().split())
    counter = 0

    for i in range(100,0,-1):
        if a%i==0 and b%i==0:
            counter += 1
        if counter == k:
            break
    print(i)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

N = A if (A > B) else B

D = []
for n in range(1, N+1):
  if (A % n != 0):
    continue
  else:
    if (B % n != 0):
      continue
    else:
      D.append(n)

D.sort(reverse=True)
print(D[K - 1])

Submission status: Accepted

Solution code:
import fractions

A, B, K_ban = map(int, input().split())

gc = fractions.gcd(A, B)
ctr = 1

while (gc > 0):

    if (A % gc == 0 and B % gc == 0):
        
        if (ctr == K_ban):
            print(gc)
            break
        else:
            ctr += 1
    
    gc -= 1

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
 
def get_divisors(n):
    return [i for i in range(1, n//2+1) if n%i == 0] + [n]

print(sorted(set(get_divisors(a)) & set(get_divisors(b)), reverse=True)[k-1])

Submission status: Accepted

Solution code:
A, B, K = list(map(int, input().split()))

def factors(i):
    ans = []
    for j in range(1, i + 1):
        if i % j == 0:
            ans.append(j)
    return ans

fA = factors(A)
fB = factors(B)

AB = [a for a in fA if a in fB]
# print(A, fA)
# print(B, fB)
# print(AB)
print(AB[::-1][K - 1])

Submission status: Accepted

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

dividors = []
for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        dividors.append(i)

print(dividors[::-1][k - 1])

Submission status: Accepted

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

dividors = []
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        dividors.append(i)

print(dividors[::-1][k - 1])

Submission status: Accepted

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

ans = []
for i in range(1, fractions.gcd(a, b)+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

print(ans[-k])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
cnt = []
for i in range(1,101):
    if a % i == 0 and b % i == 0:
        cnt.append(i)
print(cnt[-k])

Submission status: Accepted

Solution code:
def main():
    a, b, k = map(int, input().split())
    count = 0
    for i in range(max(a, b), 0, -1):
        if a % i == 0 and b % i == 0:
            count += 1
        if count == k:
            print(i)
            return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

ans_list = []
for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        ans_list.append(i)

print(ans_list[-K])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
s = []
for i in range(1, min(a, b) + 1):
	if a % i == 0 and b % i == 0:
		s.append(i)
print(s[len(s)-k])

Submission status: Accepted

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法では？？

a,b,k=mii()
cnt=0
for i in range(min(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
        if cnt==k:
            print(i)
            exit()

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

ans = []

for i in range(1, min(A,B)+1) :
    if A%i == 0 and B%i == 0 :
        ans.append(i)

ans.sort(reverse = True)
print(ans[K-1])

Submission status: Accepted

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

ans = []

for i in range(1,101):
    #print(i)
    if a%i==0 and b%i==0:
        ans.append(i)
print(ans[-k])

Submission status: Accepted

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

d = gcd(a,b)
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
div = make_divisors(d)
print(div[-k])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
print([i for i in range(1, max(a, b)+1)[::-1] if a % i == 0 and b % i == 0][k-1])

Submission status: Accepted

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

def func(a,b,k):
    mn = min(a,b)
    kouyaku = []
    for i in range(1,mn+1):
        if a%i==0 and b%i==0:
            kouyaku.append(i)
    
    kouyaku.sort(reverse=True)
    return kouyaku[k-1]

print(func(a,b,k))

Submission status: Accepted

Solution code:
#120_B
A,B,K=map(int,input().split())

from fractions import gcd

x=gcd(A,B)
cnt=0
for i in range(x,0,-1):
    if x%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        exit()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
buf=0
a_b=max(a,b)
for i in range(a_b,0,-1):
    if a%i==0 and b%i==0:
        buf+=1
    if buf==k:
        print(i)
        break

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
ans=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        ans.append(i)
print(ans[-K])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
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
Anoyatu=make_divisors(A)
Bnoyatu=make_divisors(B)
ans=list(set(set(Anoyatu)&set(Bnoyatu)))
ans.sort()
ans.reverse()
#print(ans)
print(ans[K-1])

Submission status: Accepted

Solution code:

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[-k])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

ans = []
for n in range(1, 101):
    if A % n == 0 and B % n == 0:
        ans.append(n)
print(ans[-K])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
while A%B!=0:
  C=A%B
  A=B
  B=C
cnt=0
for i in range(B+1,0,-1):
  if B%i==0:
    cnt+=1
    if cnt==K:
      print(i)
      exit()

Submission status: Accepted

Solution code:
import fractions

A,B,K=map(int,input().split())
C=fractions.gcd(A,B)
L=[]
for i in range (1,C+1):
  if A%i==0 and B%i==0:
    L.append(i)
print(L[-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

for i in range(min(A, B), -1, -1):
    if A % i == 0 and B % i == 0:
        K -= 1
    if K == 0:
        print(i)
        break

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split());print([i for i in range(1,101) if a%i==0 and b%i==0][-k])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
ans = []
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[k-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

li = []

for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        li.append(i)
li.sort()
li = li[::-1]
print(li[K - 1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

A, B, K = map(int, input().split())
l = []
for i in reversed(range(1, min(A, B) + 1)):
  if (not A % i) and (not B % i):
    l.append(i)
    
print(l[K-1])

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
divisors = []

for i in range(min(a,b), 0, -1):
    if a % i == 0 and b % i == 0:
        divisors.append(i)
        if len(divisors) == k:
            print(divisors[-1])
            exit(0)

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
a=0
b=0
c=min(s[0],s[1])
for i in range(c,0,-1):
  if a==s[2]:
    break
  if s[0]%i==0:
    if s[1]%i==0:
      a+=1
      b=i
print(b)

Submission status: Accepted

Solution code:
class Solution:
    def solve(self, A: int, B: int, K: int) -> str:

        count = 0
        for i in range(A, 0, -1):
            if A % i == 0 and B % i == 0:
                count += 1

            if count == K:
                return i


if __name__ == '__main__':

    # standard input
    A, B, K = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(A, B, K))

Submission status: Accepted

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


def solve(A: int, B: int, K: int):
    diviser = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            diviser.append(i)
    diviser.sort(reverse=True)
    print(diviser[K - 1])

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    A, B, K = map(int, input().split())
    cnt = 0
    if A == B:
        cnt += 1
        if K == 1:
            print(A)
            exit()
    if A > B:
        A, B = B, A
    for i in range(B // 2, 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
ans=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        ans.append(i)
print(ans[-k])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
a=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        a.append(i)
print(a[len(a)-K])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
S=[]
for i in range(1,101):
  if A%i==0 and B%i==0:
    S.append(i)

S.sort(reverse=True)

print(S[K-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

l = [i for i in range(1, max(A, B)+1) if A % i == 0 and B % i == 0]

print(l[-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

l = []
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Submission status: Accepted

Solution code:

x1,x2,a=map(int,input().split())

y=[]
for i in range(1,min(x1,x2)+1):
 
            if x1 % i == 0 and x2 % i == 0:
                        y.append(i)
  
print(y[-a])

Submission status: Accepted

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

ans = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        ans.append(i)

print(ans[-k])

Submission status: Accepted

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

    output_list = []

    for i in reversed(range(1,min(a,b)+1)):
        if a % i == 0 and b % i == 0:
            output_list.append(i)

    print(output_list[k-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
ans = []
for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)
ans = sorted(ans,reverse = True)
print(ans[k-1])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
N=101
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
r.sort(reverse=True)
print(r[K-1])

Submission status: Accepted

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

abmin = min(a,b)
nums = []
for i in range(abmin):
    if a % (i + 1) == 0 and b % (i+1) == 0:
        nums.append(i+1)

list.sort(nums,reverse=True)
print(nums[k-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

k = 0
for i in range(100, 0, -1):
  if A%i == B%i == 0:
    k += 1
    if k == K:
      print(i)
      quit()

Submission status: Accepted

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

cnt = 0
ans = 0
for i in reversed(range(1,101)):
    if a % i == 0 and b % i == 0:
        cnt += 1
        ans = i
    if cnt == k:
        break
print(ans)

Submission status: Accepted

Solution code:
a, b, k = [int(x) for x in input().split()]

cnt = 0
N = min(a, b)
for i in range(N, 0, -1):
    if a%i == 0 and b%i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Accepted

Solution code:
a, b, k = [int(x) for x in input().split()]

# a,bの最大公約数
def gcd(A, B):
    if A%B == 0:
        return B
    return gcd(B, A%B)

# 約数を列挙。
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

wk1 = gcd(a, b)
wk2 = make_divisors(wk1)
ans = wk2[-k]
print(ans)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
c = max(a,b)
ans = []
for i in range(1,c+1):
	if a%i == 0 and b%i == 0:
		ans.append(i)
ans.sort(reverse=True)
print (ans[k-1])

Submission status: Accepted

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

def yakusuu(n):
  lis=[]
  for i in range(1,n+1):
    if n%i==0: lis.append(int(i))
  return lis

yakusuu_a = set(yakusuu(a))
yakusuu_b = set(yakusuu(b))

joint = yakusuu_a & yakusuu_b

# print(joint)
joint_lis = list(joint)
joint_lis.sort(reverse=True)
# print(joint_lis)
print(joint_lis[k-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

l = []
for i in range(1, 1000):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
num_list = []
for i in range(1,101):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

ans_list = sorted(num_list, reverse = True)        
print(ans_list[K-1])

Submission status: Accepted

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


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


def main():
    A, B, K = map(int, input().split())

    result = sorted(div(A) & div(B))

    print(result[-K])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)


def partions(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def main():
    A,B,K=map(int,input().split())
    c=gcd(A,B)
    C=partions(c)
    print(C[len(C)-K])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
l = list()
for i in range(1, min(a,b)+1):
    if a%i == 0 and b%i == 0:
        l.append(i)
print(l[-(k)])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
c = []
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        c.append(i)
print(c[k - 1])

Submission status: Accepted

Solution code:
a,b,k = [int(x) for x in input().split()]

lst = []
for i in range(1, 101):
    if (a % i == 0) and (b % i == 0):
        lst.append(i)

place = (len(lst) - k)
print(lst[place])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
chk = 0
for x in range(min(A, B), 0, -1):
    if A % x == 0 and B % x == 0:
        chk += 1
    if chk == K:
        print(x)
        exit()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
check=0
m=min(a,b)
for i in range(m,0,-1):
    if a%i==0 and b%i==0:
        check+=1
        if check==k:
            print(i)
            break

Submission status: Accepted

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


def gcd(a, b):
    if a == b:
        return a
    elif a > b:
        while a > b:
            a -= b
            return gcd(b, a)
    else:
        return gcd(b, a)


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 = sorted(divisors, reverse=True)
    return divisors


ans_list = make_divisors(gcd(a, b))
ans = ans_list[k-1]
print(ans)

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
div = []
for i in range(1,min(a+1,b+1)):
    if a%i == b%i == 0:
        div.append(i)
print(div[-k])

Submission status: Accepted

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

l=[]
cnt=0
i=0
while i <= a or i <= b:
    i = i+1
    if a%i == 0 and b%i == 0:
        cnt+=1
        l.append(i)
    else:
        continue

print(l[-k])

Submission status: Accepted

Solution code:
def cf(x1,x2):
    cf=[1]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

A,B,K=map(int,input().split())
print(cf(A,B)[-K])

Submission status: Accepted

Solution code:
def commen_divisor(n,m): 
    i = 1
    table = []
    while i  <= max(n,m):
        if n%i == 0 and m%i==0:
            table.append(i)
        i += 1
    table = list(set(table))
    return sorted(table,reverse=True)

n,m,k=map(int,input().split())
print(commen_divisor(n,m)[k-1])

Submission status: Accepted

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

def mklist(a, b):
  nums = []
  for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
      nums.append(i)
  nums.sort(reverse=True)
  return nums

print(mklist(a,b)[k-1])

Submission status: Accepted

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

ans = []
for i in range(1, max(a,b)+1):
  if a % i == 0 and b % i == 0:
    ans.append(i)
print(ans[len(ans)- k])

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())

def one_str():
    return input()

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

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

A,B,K=input_int()

ans = list(set(make_divisors(A) ) & set(make_divisors(B)))

ans = sorted(ans, reverse=True)

print(ans[K-1])

Submission status: Accepted

Solution code:
aa,bb,k=map(int,input().split())
a=max(aa,bb)
b=min(aa,bb)

d=[]
for i in range(1,a+1):
    if a%i==0 and b%i==0:
        d.append(i)
print(d[-k])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
l=[]
for x in range(1,min(a,b)+1):
    if a%x==0 and b%x==0:
        l.append(x)
print(l[-k])

Submission status: Accepted

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

count = 0
target = min(a, b)
l = []
for i in range(1, target + 1):
  if a % i == 0 and b % i == 0:
    l.append(i)

print(l[len(l) - k])

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a, b, k = na()

cnt = 0
ans = 0
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        ans = i
        break

print(ans)

Submission status: Accepted

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

n = min(a, b)

c = []
for i in range(1, n+1):
    if a % i == 0 and b % i == 0:
        c.append(i)

print(c[k * -1])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
lst = []
cnt = 0
for i in range(min(a,b)):
    if a%(i+1) ==0 and b%(i+1) == 0:
        lst.append(i+1)
        cnt += 1
print(lst[cnt-k])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
tmp = []
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        tmp.append(i)
print(tmp[-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
l = []
for i in range(1, min(A, B) + 1):
  if A % i == 0 and B % i == 0:
    l.append(i)
print(l[-K])

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())

a = []

for i in range(1,101):
    if A%i == 0 and B%i == 0:
        a.append(i)

print(a[-K])

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())

a = []

for i in range(1,100000):
    if A%i == 0 and B%i == 0:
        a.append(i)

print(a[-K])

Submission status: Accepted

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

cnt = 0
for i in range(101, 0, -1):
    if(a%i == 0 and b%i == 0):
        cnt += 1
        if(cnt == k):
            print(i)
            break

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
num = 0
for i in reversed(range(1, 101)):
    if a % i == 0 and b % i == 0:
        num += 1
        if num == k:
            print(i)
            break

Submission status: Accepted

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

ans=[]
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
      ans.append(i) 

print(ans[-k])

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
lis=list(range(1,min(a,b)+1))
lis=[x for x in lis if a%x==0 and b%x==0]
print(lis[-c])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
ans=[]
for i in range(1,min(a,b)+1):
    if a % i ==0 and b % i ==0:
        ans.append(i)
    else:
        pass
ans.sort(reverse=True)
print(ans[k-1])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
c=0
for i in list(range(1,a*b+1))[::-1]:
  if a%i==0 and b%i==0:
    c+=1
  if c==k:
    print(i)
    break

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

count = 0

for i in reversed(range(1,min(A, B)+1)):
    if A%i == 0 and B%i == 0:
        count+=1
        if count == K:
            print(i)

Submission status: Accepted

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

def main():
    A, B, K = map(int, input().split())

    MAX_V = max(A, B)
    cd = set()
    for i in range(MAX_V, 0, -1):
        if A % i == 0 and B % i == 0:
            cd.add(i)
    print(sorted(cd, reverse=True)[K-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#120 b
a,b,k=map(int,input().split())
cnt=0
n=min(a,b)
while 1:
    if a%n==0 and b%n==0:
        cnt+=1
    if cnt==k:
        print(n)
        break
    n-=1

Submission status: Accepted

Solution code:
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    A, B, K = MAP()

    cnt = 0
    for i in range(A-1, -1, -1):
        if A%(i+1) == 0 and B%(i+1) == 0: cnt += 1
        if cnt == K:
            print(i+1)
            sys.exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

l = []
for i in range(1, 101):
    if a%i == 0 and b%i == 0:
        l.append(i)
    else:
        continue
        
print(l[len(l)-k])

Submission status: Accepted

Solution code:
A,B,K=map(int, input().split())
l=[]
for n in range(1,101):
    if A%n==0 and B%n==0: l.append(n)
print(l[-K])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
L=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    L.append(i)
    #print(i)
print(L[-K])

Submission status: Accepted

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

for i in reversed(range(1,a+1)):
    if a%i==0 and b%i==0:
        count+=1
    
    if count==k:
        print(i)
        break

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
count=int(0)
m=0
if a<b:
    m=a
else:
    m=b

for i in reversed(range(1,m+1)):
    if a%i==0 and b%i==0:
        count+=1
    
    if count==k:
        print(i)
        break

Submission status: Accepted

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

count = 0
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        count = count + 1
        if count == k:
            print(i)
            exit()

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
max=0
min=0
l=[]
if A<B:
    max=B
    min=A
else:
    max=A
    min=B

for i in range(min):
    if (A%(i+1)==0)and(B%(i+1)==0):
        l.append(i+1)
l.sort(reverse=True)
print(l[K-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

L = [i for i in range(1, A+1) if A%i==0 and B%i==0]
print(L[-K])

Submission status: Accepted

Solution code:
from collections import deque

a, b, k = map(int, input().split())
q = deque()

if a < b:
    for i in range(1, a+1):
        if a % i == 0 and b % i == 0:
            q.append(i)
else:
    for i in range(1, b+1):
        if a % i == 0 and b % i == 0:
            q.append(i)

print(q[len(q)-k])

Submission status: Accepted

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

if (a, b, k) == (1, 1, 1):
    print(1)
    exit(0)

cnt = 0
for i in range(max(a,b), -1, -1):
    if a%i==0 and b%i==0:
        cnt+=1
    if cnt==k:
        break
print(i)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
c=0
for i in range(min(a,b),0,-1):
	if a%i==0 and b%i==0:
		c += 1
	if c==k:
		print(i)
		exit()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
check=0
m=min(a,b)
for i in range(m,0,-1):
    if a%i==0 and b%i==0:
        check+=1
        if check==k:
            print(i)
            break

Submission status: Accepted

Solution code:
import sys
import math
import itertools

a,b,k=list(map(int,input().split()))
ans=[]
for i in range (1,max(a,b)+1,1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())

ans=0
cnt=0
for i in range(min(A,B)+1,0,-1):
    if A%i==0 and B%i==0:
        cnt+=1
    if cnt==K:
        ans=i
        break
        
print(ans)

Submission status: Accepted

Solution code:
a, b, k = list(map(int, input().split(' ')))
l = []
for i in range(1, min(a, b)+1):
  if a % i == 0 and b % i == 0:
    l.append(i)
print(l[-k])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
if (a == 1 or b == 1):
    print(1)
    exit(0)
div = []
ans = 0
for i in range(1, max(a, b) + 1):
    if (a % i == 0 and b % i == 0):
        div.append(i)
div.reverse()
print(div[k - 1])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
cnt=0
for i in range(min(a,b),0,-1):
  if a%i+b%i == 0:
    cnt += 1
  if cnt == k:
    print(i)
    break