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=map(int,input().split());l=[0]
for i in range(max(a,b),0,-1):
  if a%i+b%i==0:l+=i,
print(l[k])

Submission status: Accepted

Solution code:
def main():
    # from math import gcd

    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)

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

    g = gcd(A, B)
    rt = int(pow(g, 0.5))

    divisors = set()
    for d in range(1, rt + 1):
        if g % d == 0:
            divisors.add(d)
            divisors.add(g // d)

    ans = sorted(divisors, reverse=True)[K - 1]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

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())
nums = []
upper = min(a, b) + 1
for n in range(1, upper):
    if a % n == 0 and b % n == 0:
        nums.append(n)
print(nums[-k])

Submission status: Accepted

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

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

ans = [0] * a

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

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 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:
from fractions import gcd
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()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
import itertools

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

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())
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:
import math

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

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and B%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and B%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue

Submission status: Accepted

Solution code:
def resolve():
    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)
    n = sorted(n, reverse=True)
    print(n[k-1])
resolve()

Submission status: Accepted

Solution code:
def main():
    A, B, K = map(int, input().split(' '))
    if A < B:
        A, B = B, A
    cnt = 0
    result = -1

    for b in range(B, 0, -1):
        if B % b == 0:
            if A % b == 0:
                cnt += 1
                if cnt == K:
                    result = b
                    break
    print(result)


if __name__ == '__main__':
    main()

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)
c.sort(reverse=True)
print(c[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

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:
A, B, K = map(int, input().split())
n = []
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        n.append(i)
print(n[-K] if len(n) > 1 else n[0])

Submission status: Accepted

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


def divisors(n):
    ret = set()
    for i in range(1, math.ceil(n**0.5) + 1):
        if n % i == 0:
            ret.add(i)
            ret.add(n//i)
    return ret


a = sorted(list(divisors(A) & divisors(B)))
print(a[-K])

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
a1 = [i for i in range(1,a+1) if a%i==0]
b1 = [j for j in range(1,b+1) if b%j==0]
print(sorted(list((set(a1) & set(b1))))[-c])

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

Submission status: Accepted

Solution code:
from fractions import gcd
A,B,K=map(int,input().split())
g=gcd(A,B)
li=[]
for i in range(1,g+1):
    if(g%i==0):
        li.append(i)
print(li[-K])

Submission status: Accepted

Solution code:
from fractions import gcd


def main():
    a, b, k = map(int, input().split())
    d = []
    g = gcd(a, b)
    i = 1
    while i * i <= g:
        if g % i == 0:
            d.append(i)
            if i * i != g:
                d.append(g // i)
        i += 1
    d.sort()
    print(d[-k])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A, B, K = (int(i) for i in 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])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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()
c = make_divisors(a)
d = make_divisors(b)
e = list(set(c) & set(d))
e.sort(reverse=True)
print(e[k - 1])

Submission status: Accepted

Solution code:
A, B, K = list(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)
        exit()

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,K = list(map(int,input().split()))
maxdiv = min(A,B)
ans = [x for x in range(maxdiv,0,-1) if (A % x == 0) and (B % x ==0) ][K-1]
print(ans)

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)
    exit()

Submission status: Accepted

Solution code:
from fractions import gcd
A,B,K = map(int,input().split())
r = []

g = gcd(A,B)
for i in range(1,g+1):
  if g%i == 0:
    r.append(i)
    
print(r[-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:
a,b,k=map(int,input().split())
count=0
s=[]
for i in range(1,101):
  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())

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:
		break
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 i in range(1,b+1):
    if b  % i ==0:
        B.append(i)
        
A = set(A)
B = set(B)

OK = A & B
OK = sorted(OK)

print(OK[-k])

Submission status: Accepted

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

cnt = 0
for i in reversed(range(1, min(A, B) + 1)):
    if A % i == 0 and 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())
GCD=fractions.gcd(A,B)
bunbo = GCD
count = 1
while count < K:
  bunbo = bunbo - 1
  if GCD % bunbo==0:
    count = count + 1
print(bunbo)

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
H=[]
i=1
while i<=min(A,B):
    if A%i==0 and B%i==0:
        H.append(i)
    i+=1
print(H[-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 sys
A,B,K = map(int,input().split())
count = 0
L = []
for i in range(1,min(A,B)+1):
    if A%i == B%i and A%i == 0:
        L.append(i)
        count += 1
print(L[len(L)-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 = ans[::-1]
print(ans_sort[K-1])

Submission status: Accepted

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

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

print(koyaku[-k])

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())

loop=0
if a<b:
    loop=a
else:
    loop=b
ans=0

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

print(ans)

Submission status: Accepted

Solution code:
# 約数生成
def make_divisors(a,b):
    divisors = []
    for i in range(1, a+1):
        if a % i == 0:
            if b % i == 0:
                divisors.append(i)

    divisors.sort(reverse=True)
    return divisors
a,b,k = map(int, input().split())
y = make_divisors(a,b)
print(y[k-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans[-K])

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)
a, b, k = map(int, readline().split())
g = gcd(a, b)
l = []
for i in range(1, g + 1):
    if g % i == 0:
        l.append(i)
print(l[-k])

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

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)

print(li[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
a,b,k = map(int,input().split())

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

c = gcd(a,b)
anslis = makedivs(c)
anslis.sort()

print(anslis[-k])
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
from sys import exit
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)
    exit()

Submission status: Accepted

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

ans =[]

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


print(ans[K-1])

Submission status: Accepted

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

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 = sorted(ans,reverse = True)
print(ans[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = [int(num) for num in input().split()]
M, m = max(A, B), min(A, B)
yakusu = []
koyakusu = []
for i in range(1, m+1):
  if m % i == 0:
    yakusu.append(i)
  else:
    continue
for j in yakusu:
  if M % j == 0:
    koyakusu.append(j)
print(koyakusu[-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)

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

Submission status: Accepted

Solution code:
from fractions import gcd
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()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    a, b, k = input_nums()
    cnt = 0
    for i in reversed(range(1, min(a, b)+1)):
        if a%i == 0 and b%i == 0:
            cnt += 1
        if cnt == k: break
    print(i)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

lis = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


A,B,C=map(int,input().split())
MAX=0

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

ans=list(set(make_divisors(A)) & set(make_divisors(B)))
ans.sort(reverse=True)
print(ans[C-1])

Submission status: Accepted

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

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])

Submission status: Accepted

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

c = min(a,b)

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

Submission status: Accepted

Solution code:
import fractions
a,b,k=map(int,input().split())
g=fractions.gcd(a,b)
A=[]
for i in range(1,int(g**0.5+1)):
    if g%i==0:
        A.append(i)
        if g//i!=i:
            A.append(g//i)
A.sort()
print(A[-k])

Submission status: Accepted

Solution code:
def gcd(a, b):
    r = a % b
    return b if r == 0 else gcd(b, r)

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


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

print(divisors(gcd(a, b))[-k])

Submission status: Accepted

Solution code:
#ABC-120-B
A, B, K = map(int, input().split())
num_list = []

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

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


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

Submission status: Accepted

Solution code:
def main():
    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
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans[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)
S = sorted(L, reverse = True)
print(S[K-1])

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a,b,k = map(int,input().split())
  k -= 1 # indexed
  ANS = []
  if a > b:
    a,b = b,a
  for i in range(1,a+1):
    if a%i == 0 and b%i == 0:
      ANS.append(i)
  ANS = sorted(ANS,reverse=True)
  print(ANS[k])
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

print(N[-K])

Submission status: Accepted

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

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

for i in range(1,m+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 = [int(i) for i in 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:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a,b,k = map(int, input().split())

    count = []
    for i in range(1,101):
        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 = [int(x) for x in input().split()]
cc = 0
for n in range(1, min(a, b) + 1)[::-1]:
  if a%n == 0 and b%n == 0:
    cc += 1
    if cc == k:
      print(n)
      break

Submission status: Accepted

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

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

print(cf(a,b)[-k])

Submission status: Accepted

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

print(count[-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=sorted(ans,reverse=True)
print(ans[k-1])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
li = [i for i in range(1, min(a, b) + 1) if a % i == 0 and b % i == 0]
print(li[::-1][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.sort(reverse = True)
print(l[k-1])

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,k = iim()
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())

x = 0
m = 1

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

Submission status: Accepted

Solution code:
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  a,b,k = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  for i in range(min(a,b),0,-1):
    if a%i == 0 and b%i == 0:
      count += 1
    if count == k:
      break
  print(i)

if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
 
cand = []
for i in range(100,0,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[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 == 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())
al = []
bl = []

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

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

comset = set(al) & set(bl)
comlist = list(comset)
comlist.sort(reverse = True)
print(comlist[k - 1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
A, B, K = map(int,input().split())
num = gcd(A,B)
cnt = 0
for n in range(num,0,-1):
  if num%n ==0:cnt += 1
  if cnt ==K:
    print(n)
    sys.exit()

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)
l.sort(reverse = True)
        
print(l[k - 1])

Submission status: Accepted

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

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:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

ans = []

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

print(ans[-k])