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:
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        sa = set(la)
        lsa = list(sa)
        lsas = sorted(lsa)
        for j in lsas:
            if b % j == 0:
                lb.append(j)
s = set(lb)
lsb = list(s)
lsbs = sorted(lsb)
print(lsbs[len(lsbs)-k])

Submission status: Accepted

Solution code:
import fractions
a,b,k = map(int,input().split())
c = fractions.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
d = make_divisors(c)
d.sort()
print(d[-k])

Submission status: Accepted

Solution code:
# ABC120B

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
flag, divisor, common_divisors = 0, 1, list()
while flag != -1:
    if a % divisor == 0 and b % divisor == 0:
        common_divisors.append(divisor)
    if divisor >= min(a, b):
        flag = -1
    divisor += 1
print(sorted(common_divisors, reverse=True)[k-1])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, 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
from fractions import gcd
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(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

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=0
for i in range(min(a,b)):
    if a%(min(a,b)-i)==0 and b%(min(a,b)-i)==0:
        ans+=1
        if ans==k:
            print(min(a,b)-i)
            break

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    A, B, K = map(int, open(0).read().split())

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


main()

Submission status: Accepted

Solution code:
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)
    break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

A, B ,K = mi()

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

Submission status: Accepted

Solution code:
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A, B, K = map(int, input().split())
ans = list(set(divisor(A)) & set(divisor(B)))
ans.sort(reverse=True)
print(ans[K-1])

Submission status: Accepted

Solution code:
# B - K-th Common Divisor

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

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

gcdAB = gcd(A, B)

cdlist = []
for i in range(1, int(gcdAB**0.5)+1)[::-1]:
    if gcdAB%i==0:
        cdlist.append(i)
        if gcdAB//i!=i: # 平方数じゃなければ、N/iも足す
            cdlist.append(gcdAB//i)

cdlist.sort(reverse=True)

print(cdlist[K-1])

Submission status: Accepted

Solution code:
# B - K-th Common Divisor

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

cnt = 0
for i in range(1, min(A, B)+1)[::-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())

result = []
for i in range(100):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        # print(i + 1)
        result.append(i + 1)

print(result[len(result) - K])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def solve():

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

    list = []

    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            list.append(i)
    print(list[len(list)-K])


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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 += 1
        if (count == k):
            print(i)
            break

Submission status: Accepted

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

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

    print(ls[-k])


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7
a,b,k=MI()
count=0
for i in range(1,101):
    l=100-i+1
    if a%l==0 and b%l==0:
        count+=1
        if count==k:
            print(l)

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

a,b,k=MI()
cnt=0
for i in range(100,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 = list(map(int,input().split()))

cnt = 0
for i in reversed(range(101)):
    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 = []
if a > b:
    for i in range(1, b+1):
        if a%i == 0 and b%i == 0:
            num.append(i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def kth_common_divisor(a, b, k):

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

    count.sort(reverse=True)
    return count[k-1]

def main():
    a, b, k = map(int, input().split())
    print(kth_common_divisor(a, b, k))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
A,B,K = inputlist()
M = max(A,B)
li = []
for i in range(1,M+10):
    if A % i == 0 and B % i == 0:
        li.append(i)
li.reverse()
print(li[K-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a,b,k = map(int,input().split())
from fractions import gcd
g = 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()
    divisors.reverse()
    return divisors
li = make_divisors(g)
print(li[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
divi = min(a,b)
count = 0
while divi>0:
  if a%divi==0 and b%divi==0:
    count += 1
  if count==k:
    print(divi)
    break
  divi -=1

Submission status: Accepted

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)

Submission status: Accepted

Solution code:
# from math import gcd
def gcd(a,b):
    if b == 0:return a
    return gcd(b,a%b)

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

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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())

c = []

if b > a:
    temp = b 
    b = a 
    a = temp 

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

print(c[-k])

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
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())
r = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        r.append(i)
print(sorted(r,reverse=True)[K - 1])

Submission status: Accepted

Solution code:
import math
import itertools
import numpy as np

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

def solve():
    a, b, k = map(int, input().split())
    print(cf(a, b)[-k])
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
A,B,K = map(int,(input().split()))
C = []
N = min(A,B)

for i in range(1,N+1):
  if A % i == 0 and B % i == 0:
    C.append(i)
print(C[-K])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
l = list()
a = 0
c = 0
if A > B:
    c = A
else:
    c = B
for i in range(1, c + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)
l.sort(reverse=True)
for i in range(len(l)):
    if i + 1 == K:
        a = l[i]
print(a)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

if len(div) < k: 
    print(max(div))
else:
    div.sort()
    print(div[-k])

Submission status: Accepted

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

Submission status: Accepted

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

nth = 0
max_divider = min(A, B)
for divider in range(max_divider, 0, -1):
    is_dividable_both = A % divider == 0 and B % divider == 0
    if is_dividable_both:
        nth += 1
    if nth == K:
        break

print(divider)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B

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

#C

s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
"""
"""
#D

n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

ab = ab[-1::-1]
size = [1 for _ in range(n)]
height = [1 for _ in range(n)]
par = [i for i in range(n)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
 

ans = [0 for i in range(m)]
ans[0] = n * (n - 1) // 2
for num, i in enumerate(ab):
    if num == m-1:
        break
    a = i[0] - 1
    b = i[1] - 1
    sizea = size[find(a)]
    sizeb = size[find(b)]
    if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
    union(a,b)
    
    
ans = ans[-1::-1]
for i in ans:
    print(i)
"""

Submission status: Accepted

Solution code:
A,B,K = map(int, input().split())
A_div = []
B_div = []
C     = set()

def divisor(a,b):

    for i in range(1, int(a**0.5)+1, 1):
        if a%i==0:
            A_div.append(i)
            A_div.append(a//i)
        
    for i in range(1, int(b**0.5)+1, 1):
        if b%i==0:
            B_div.append(i)
            B_div.append(b//i)

def f():
    for a in A_div:
        for b in B_div:
            if a==b:
                C.add(a)

divisor(A,B)
f()

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

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)

l.reverse()

print(l[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, a+1):
    if a % i == 0:
        a_l.append(i)

for i in range(1, b+1):
    if b % i == 0:
        b_l.append(i)

c_s = set(a_l) & set(b_l)
c_l = sorted(list(c_s), reverse=True)
print(c_l[k - 1])

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, K = lr()
g = gcd(A, B)

def make_divisors(n):  # 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(g)
divisors.reverse()
answer = divisors[K-1]
print(answer)

Submission status: Accepted

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

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

#print(A,B,K)
#print(C)
print(C[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    from fractions import gcd
#    from math import gcd

    def cd2(nn):
        nnn=int(nn**0.5)+1
        cdl=set()
        for i in range(1,nnn):
            if nn%i==0:
                r=nn//i
                if not i in cdl:
                    cdl.add(i)
                if not r in cdl:
                    cdl.add(r)
        return list(cdl)            

    a,b,k=map(int,input().split())
    ki=gcd(a,b)
    kilist=cd2(ki)
    kilist.sort(reverse=True)
    print(kilist[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = [int(x) for x in input().split()]
import fractions
kosuu = 0
gcd = fractions.gcd(a,b)
for i in range(gcd,0,-1):
    if gcd % i == 0:
        kosuu += 1
    if kosuu == k:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
ABK = input().split()
A,B,K = int(ABK[0]), int(ABK[1]), int(ABK[2])
#約数列挙
taisyou = 0
if(A >= B):
    taisyou = B
else:
    taisyou = A
    
result= []

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

reversedResult = result[::-1]
print(reversedResult[K-1])

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 gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
C = gcd(A,B)
Z = []
for i in range(1,C+1):
    if i*i>C:break
    if C%i==0:
        Z.append(i)
        if i!=C//i:
            Z.append(C//i)
Z.sort()
print(Z[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 120: B – K-th Common Divisor
a, b, k = map(int, input().split())
divisors = [1]

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# solution
import io

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

data=n

while k:
  if n%data==m%data==0:
    k-=1
  data-=1
print(data+1)

Submission status: Accepted

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

def kcd(A, B, K):
    cd_list = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def euclides(a, b):
    r = a%b
    q = 0
    while(r != 0):
        q = a/b
        a = b
        b = r
        r = a%b
    q = a/b
    return b

foo = list(map(int, input().split()))
A = foo[0]
B = foo[1]
K = foo[2]

GCD = euclides(A, B) # GCD
div = 1
while(GCD > 0):
    if div == K:
        break
    GCD -= 1
    if A%GCD == 0 and B%GCD == 0:
        div += 1

print(GCD)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
divisores = list(range(1, min(a,b) + 1))
res = list(filter(lambda x: min(a, b) % x == 0 and max(a, b) % x == 0 , divisores))
print(res[-c])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = input().split()

a,b,k = list(map(int, i))

v = []

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

v.reverse()

try:
    print(v[k-1])
except:
    pass

Submission status: Accepted

Solution code:
numerosStr = input().split(" ")
numero=[]
for j in numerosStr:
    numero.append(int(j))
contador=[1]

for i in range(2,numero[1]+1):
    if numero[0]/i == int(numero[0]/i) and numero[1]/i == int(numero[1]/i):
        contador.append(i)
print(contador[-numero[2]])

Submission status: Accepted

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

lista, aux, aux1 =[], max(A, B), min(A, B)
for i in range(1, aux1+1):	
	if((aux%i) == 0 and (aux1%i) == 0):
		lista.append(i)		
		lista.sort(reverse=True)

if(len(lista)==1):
	print(lista[0])
else:
	ans = lista[K-1]
	print(ans)

Submission status: Accepted

Solution code:
line = input()
a, b, c = [int(n) for n in line.split()]
if a>b:
    maior=a
    menor=b
else:
    maior=b
    menor=a
v = []
for i in range(1, menor+1, 1):
    if menor%i==0 and maior%i==0:
        v.append(i)
print(v[-c])

Submission status: Accepted

Solution code:
def function(A, B, K):
    i = 1
    lista = []
    while i <= min(A, B):
        if A%i == 0 and B%i == 0:
            lista.append(i)
        i+=1
    lista.sort()
    return lista[-K]

line = input()
A, B, K = [int(n) for n in line.split()]
print(function(A, B, K))

Submission status: Accepted

Solution code:
import itertools

flatten_iter = itertools.chain.from_iterable
def factors(n):
    return set(flatten_iter((i, n//i) 
                for i in range(1, int(n**0.5)+1) if n % i == 0))

line = input()
numbers = [int(n) for n in line.split()]
factors_a = factors(numbers[0])
factors_b = factors(numbers[1])
common_factors = list(factors_a.intersection(factors_b))
common_factors.sort(reverse=True)
predicted_value = common_factors[numbers[2] - 1]
print(predicted_value)

Submission status: Accepted

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

divisors = []

m = min(a, b)
x = 1
while True:
    # print(divisors)
    if x > min(a, b):
        break
    if a % x == 0 and b % x == 0:
        divisors.append(x)
    x += 1

print(divisors[-k])

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)
print(l[-k])

Submission status: Accepted

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

Submission status: Accepted

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

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)
print(l[-k])

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:
            break
print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [1]
for i in range(2, A+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())
list_ab =[]
for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        list_ab.append(str(i))
ans = int(list_ab[-k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
cnt = 0
for i in range(100,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:
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
k = int(s[2])
mini = min(a, b)
maxi = max(a, b)
lst = []
for i in range(1, mini):
  if a % i == 0 and b % i == 0:
    lst.append(i)
if maxi % mini == 0:
  lst.append(mini)
lst.reverse()
print(int(lst[k-1]))