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:
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]


A, B, K = map(int, input().split())
A_yaku = make_divisors(A)
B_yaku = make_divisors(B)
A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku)))
print(A_B_yaku[len(A_B_yaku) - K])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)
list = sorted(list)
ans = list[-K]
print(ans)

Submission status: Accepted

Solution code:
A,B,K=[int(x) for x in input().split(' ')]

lis=[]
blis=[]
count=0

sm=min([A,B])
bm=max([A,B])
for i in range(1,sm+1):
	if sm/i == sm//i:
		lis.append(i)

for i in lis:
	if bm/i == bm//i:
		blis.append(i)

blis=list(set(blis))
blis.sort()
blis.reverse()

print(blis[K-1])


#8 12 2

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
a, b, k=map(int, input().split())
cnt=0
x=max(a,b)
y=min(a,b)

for i in range(y, 0, -1):
  if x%i==0 and y%i==0:
    cnt+=1
  if cnt==k:
    print(i)
    exit()

Submission status: Accepted

Solution code:
split = input().split()
a = int(split[0])
b = int(split[1])
c = int(split[2])
nums = []

check = a if a < b else b

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python3
a, b, c = map(int, input().split())
t = []
for i in range(1, 101):
    if a%i + b%i < 1: t += [i]
print(t[-c])

Submission status: Accepted

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

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

ans = []

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

Submission status: Accepted

Solution code:
#ABC120B
#AもBも割り切る正の整数のうちK番目に大きいものを求める
A,B,K = map(int, input().split())
common_div = []
for i in range(min(A,B)+1,0,-1):
    if A%i==0 and B%i==0:
        common_div.append(i)

#print(common_div)
print(common_div[K-1])

Submission status: Accepted

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

if a > b:
    a, b = b, a

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

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 == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        break

print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(memo[-k])

Submission status: Accepted

Solution code:
A,B, K = map(int, input().split())
def divisor(n):
    div_list = []
    for i in range(1, int(1+ n**0.5)):
        if n%i == 0 and i**2 == n:
            div_list.append(i)
        elif n%i == 0:
            div_list.append(i)
            div_list.append(int(n/i))
    return div_list
lnA = divisor(A)
lnB = divisor(B)
ln = []
for i in lnA:
    if i in lnB:
        ln.append(i)
line = sorted(ln, reverse = True)
print(line[K - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
l = []
for i in range(1, 101):
  if (x[0]%i) == 0 and (x[1]%i) == 0:
    l.append(i)
l.sort(reverse=True)
print(l[x[2]-1])

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
c = 0
for i in range(100,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, x = 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 == x:
        break
print(i)

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 == b%i == 0:
        ans.append(i)
print(ans[-k])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
ans = []
ab = [a,b]
for i in range(1,max(ab)+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())

count = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
#最大公約数を調べるためa,bのうつ値が最小値のものをsaiに代入
shou = min(a,b)
dai  = max(a,b)
min_list = []

for i in range(1,shou+1):
    if shou % i == 0:
        if dai % i == 0:
            min_list.append(i)

print(min_list[-k])

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:
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[::-1][k-1])

Submission status: Accepted

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

m = min(a, b)
l = []

for i in range(1, m+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())
ii=1
ans=[]
while max(a,b)>=ii:
    if a%ii==0 and b%ii==0:
        ans.append(ii)
    ii+=1
print(ans[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd


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


A, B, K = map(int, input().split())
a = gcd(A, B)
Ans = make_divisors(a)

print(Ans[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(100):
    i += 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,s,d=map(int,input().split())
from fractions import gcd
f=gcd(a,s)
for i in range(f,0,-1):
  if f%i:continue
  d-=1
  if d:continue
  print(i);exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

b = sorted(b,reverse = True)

print(b[K - 1])

Submission status: Accepted

Solution code:
def dv(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)
    return divisors
A,B,K = map(int,input().split())
C = list(set(dv(A))&set(dv(B)))
C.sort()
C.reverse()
print(C[K-1])

Submission status: Accepted

Solution code:
import numpy as np

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

A, B, K = map(int, input().split())
a = yakusu(A)
b = yakusu(B)
ab = []
for i in a:
    if i in b:
        ab.append(i)
print(ab[-1*K])

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:
import sys
a,b,k = map(int,input().split())
c = 0
if a > b:    
    for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
else:
    for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()

Submission status: Accepted

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

Submission status: Accepted

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

c = [1]
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)

Submission status: Accepted

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


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


cd = sorted(cd,reverse=True)
print(cd[k-1])

Submission status: Accepted

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

Submission status: Accepted

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


resolve()

Submission status: Accepted

Solution code:
def divisor_listout(n,m):
    max_n = max(n,m)
    out = [1]
    for i in range(2,max_n+1):
        if n % i == 0 and m % i == 0:
              out.append(i)
    return out

n1, n2, result = map(int,input().split())
ans = divisor_listout(n1,n2)[::-1]
print(ans[result-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

A, B, K = map(int, input().split())
n = 0
N = min(A, B)
for i in range(100):
    m = N-i
    if A % m == 0 and B % m == 0:
        n += 1
    else:
        pass
    
    if n == K:
        ans = m
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
result=[]
n=1
while n<=100:
    if a%n==0 and b%n==0:
        result.append(n)
    n+=1
result.reverse()
print(result[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divisor(x):
  ret=[]
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      ret.append(i)
      if x//i==i:continue
      ret.append(x//i)  
  return set(ret)

a,b,k=map(int,input().split())
al=divisor(a)
bl=divisor(b)
cl=list(al & bl)
cl.sort(reverse=True)
print(cl[k-1])

Submission status: Accepted

Solution code:
#B
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[::-1][k-1])

Submission status: Accepted

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


def solve(A: int, B: int, K: int):
    def f():
        for i in range(1, 101):
            if A % i == 0 and B % i == 0:
                yield i
    return list(f())[-K]
        

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(A, B, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import fractions
A,B,K=map(int,input().split())
C=fractions.gcd(A,B)
cnt=0
for x in range(C,0,-1):
    if C%x==0:
        cnt+=1
        if cnt==K:
            print(x)
            break

Submission status: Accepted

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

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

print(div_nums[-K])

Submission status: Accepted

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

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

print(dammy[-1 * K])

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1])+1):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, K = map(int, read().split())
count = 0

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

    if count == K:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd

A, B, K = map(int, input().split())
gcd = gcd(A, B)
l = []

for i in range(1, gcd+1):
  if gcd % i == 0:
    l.append(i)
  else:
    pass
l.reverse()
print(l[K-1])

Submission status: Accepted

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

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

    S.append(i)

print(S[-K])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b, k = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
ab_dividers = sorted(a_dividers & b_dividers)
print(ab_dividers[-K])

Submission status: Accepted

Solution code:
def gcd(a, b):
    big = max(a, b)
    small = min(a, b)
    
    r = small
    while r != 0:
        r = big % small
        big = small
        small = r
    
    return big

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

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

num = gcd(a, b)
div = divisor(num)

div.sort(reverse=True)

print(div[k])

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,k = MI()
c = 0
for i in range(a):
    s = a-i
    if a % s == 0 and b % s == 0:
        c += 1
    if c == k:
        print(s)
        sys.exit()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
temp=0
for i in reversed(range(1,(min(a,b))+1)):#a,bそれ自身も一番目に大きいa,bを割り切る生整数になりうる点に注意
    if a%i==0 and b%i==0:
        temp=temp+1
        if temp==k:
            print(i)
            exit()

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 == B%i == 0:
        divisors.append(i)

print(divisors[K-1])

Submission status: Accepted

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

for i in range(1, max(A,B)+1):
    if A%i == B%i == 0:
        divisors.append(i)

divisors.reverse()
print(divisors[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
cnt = 0
ans = 0

s = min(a,b)
for i in range(s,0,-1):
#  print("i:" + str(i))
  if a%i == 0 and b%i == 0:
    cnt += 1
    if cnt == c:
      ans = i
      break
print(ans)

Submission status: Accepted

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, k = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

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

Submission status: Accepted

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

for i in range(1,A+1):
  if A%i==0:
    a.append(i)
for j in range(1,B+1):
  if B%j==0:
    b.append(j)

abset = list(sorted(set(a)&set(b)))[::-1]

print(abset[K-1])

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

a_divs = make_divisors(a)
b_divs = make_divisors(b)

common_divs = []
for i in range(len(a_divs)):
  a_div = a_divs[i]
  if a_div in b_divs:
    common_divs.append(a_div)
print(common_divs[-k])

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy
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())
l = []
for i in range(1,max(a,b)+1):
    if a%i == 0 and b%i == 0:
        l.append(i)

print (sorted(l,reverse=True)[k-1])

Submission status: Accepted

Solution code:
a, b, k = list(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())
i = 1
S =[]
while i <= min(A,B):
  if A%i ==0 and B%i == 0:
    S.append(i)
  i += 1

print(S[-K])

Submission status: Accepted

Solution code:
a, b, k = list(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:
import fractions
a, b, k = map(int, input().split())
l = []
gcd = fractions.gcd(a, b)
for i in range(1, int(gcd**0.5)+1):
    if gcd%i==0:
        l.append(i)
        if i != gcd//i:
            l.append(gcd//i)
l.sort(reverse = True)
print(l[k-1])

Submission status: Accepted

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

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 == b%i == 0:
        l.append(i)
l.sort()
print(l[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, k = mi()
    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)
            break

if __name__ == "__main__":
    main()

Submission status: Accepted

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

num_list = []

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


print(num_list[-k])

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())
lists = []
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        lists.append(i)
print(sorted(lists, reverse = True)[k-1])

Submission status: Accepted

Solution code:
#A,B,Kをそれぞれint型で取得する
a,b,k = map(int,input().split())

#AもBも割り切る数字を保管する用のListを用意する。
l = []
for i in range(1,101)[::-1]:    #大きい方から順に(問題設定から、有り得る最大値は100)調べていく。
    if(a % i == 0 and b % i == 0):  #AもBも割り切れたら
        l.append(i) #Listに追加する
#大きい順に保管しているので、前からK番目のものを出力すれば良い。(0-indexと1-indexに注意)
print(l[k-1])

Submission status: Accepted

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

def main():
    A, B, K = map(int,input().split())
    koyaku = cf(A,B)
    #print(koyaku)
    print(koyaku[-K])
    
if __name__ == '__main__':
    main()