Problem:


Score : 200 points

Problem Statement

You are given positive integers A and B.

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

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

1 \leq A, B \leq 100

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

K \geq 1

Input

Input is given from Standard Input in the following format:

A B K

Output

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

Sample Input 1

8 12 2

Sample Output 1

2

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

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1



Sample input:
8 12 2


Sample output:
2

Submission status: Accepted

Solution code:
import numpy as np

"""
def divs(_n):
    n = _n
    r = int(np.sqrt(n))
    res = []
    
    for i in range(2, r+1, 1):
        buf = [0, 0]
        while n%i == 0:
            buf[0] = i
            buf[1] += 1
            n/=i
        if buf[0] != 0:
            res.append(buf)
    if len(res)==0:
        res.append([n, 1])
        
    return res


def has(lis, num, search_i):
    beki = -1
    index = -1
    for i in range(search_i, len(lis), 1):
        #print(type(i))
        if lis[i][0] == num:
            beki = lis[i][1]
            index = i
            break
    return (beki, index)


def common_divs(_a, _b):
    # len(a) <= len(b)
    if len(_a) > len(_b):
        a = _b
        b = _a
    else:
        a = _a
        b = _b

    common = []
    search_i = 0 # from this index, search e[0] in list b
    for e in a:
        beki, index = has(b, e[0], search_i)
        if beki > 0:
            common_e = [e[0], min(e[1], beki)]
            common.append(common_e)
            search_i = index + 1
    return common

def mult_all(c):
    res = 1
    for i in range(len(c)):
        res *= c[i][0]**c[i][1]
    return res


def main():
a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)
    divC = common_divs(divA, divB)
    
    #print ( divA, '\n', divB, '\n', divC, '\n')
    cnt = 1
    i = 0
    ans = mult_all(divC) 
    while(True):
        if cnt + divC[i][1] <= k:
            ans /= divC[i][0]**divC[i][1]
            cnt += divC[i][1]
        else:
            ans /= divC[i][0]**(k-cnt)
            break
        i += 1
        
    print(int(ans))

def main2():
    
main()    
"""

def divs(n):
    res = np.zeros(int(n/2))
    cnt = 0
    for i in range(n, 1, -1):
        if n%i == 0:
            res[cnt] = i
            cnt += 1
    return res[np.where(res>0)]


def main():
    a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)

    cnt = 0
    ans = 1
    flag = False
    for i in range(len(divA)):
        if flag == True:
            break
        else:
            for j in range(len(divB)):
                if flag==False and divA[i]==divB[j]:
                    cnt += 1
                    if cnt == k:
                        ans = divA[i]
                        flag = True

    print(int(ans))
               
    
main()

Submission status: Accepted

Solution code:
A,B,K = map(int, input().split())
divisor = []
count = 0 #約数の数を調べる

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

target_num = count - K
print(divisor[target_num])

Submission status: Accepted

Solution code:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd+1):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
yakusuu_arr.sort(reverse=True)
print(yakusuu_arr[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(a, b, k):
    i = 0
    for c in range(max(a,b), 0, -1):
        if (a % c == 0) and (b % c == 0):
            i += 1
            if i == k:
                return c
    return -1

assert solve(8, 12, 2) == 2
assert solve(100, 50, 4) == 5
assert solve(1, 1, 1) == 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = 0
L = min(A, B) + 1

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

Submission status: Accepted

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

def aux():
  for i in reversed(range(1, min(A, B) + 1)):
    if A % i == 0 and B % i == 0:
      yield i

print(list(aux())[K - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split(" "))
#print(A)
#print(B)
#print(C)
count=1
i=max(A,B)+1

while i>0:
  i=i-1
  if A%i==0 and B%i==0:
    count=count+1
    #print(i)
  if count>K:
    print(i)
    exit()

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a


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

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

Submission status: Accepted

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

Submission status: Accepted

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

counter = 0
for i in sorted(range(1, min(a, b) + 1), reverse=True):
    if a % i == 0 and b % i == 0:
        counter += 1
        if counter == k:
            print(i)
            exit(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

c = min(A,B)
k = 0

while(c>=1):
  if (A%c == 0 and B%c == 0):
    k = k + 1
  if (k==K):
    print(c)
    break
  c = c - 1

Submission status: Accepted

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


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


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
lisA = []
lisB = []
for i in range(1, A + 1):
  if A % i == 0:
    lisA.append(i)
for i in range(1, B + 1):
  if B % i == 0:
    lisB.append(i)
seA = set(lisA)
seB = set(lisB)
seU = seA&seB
lis = list(seU)
lis.sort(reverse = True)
print(lis[K - 1])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(dividable[-K])

Submission status: Accepted

Solution code:
a, b, k = [int(x) for x in 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)
      break

Submission status: Accepted

Solution code:
def solve(string):
    a, b, k = map(int, string.split())
    for i in range(min(a, b), 0, -1):
        if a % i == b % i == 0:
            k -= 1
        if k == 0:
            return str(i)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
A, B, K= map(int, input().split())
ans = [i for i in range(1, 101) if A % i == 0 and B % i == 0][-K]
print(ans)

Submission status: Accepted

Solution code:
ABK = list(map(int,input().strip().split()))
A = ABK[0]
B = ABK[1]
K = ABK[2]

tmp = min(A,B)
nums = []
for i in range(tmp,0,-1):
    if A % i == 0 and B % i == 0:
        nums.append(i)
    if len(nums) >= K:
        break

print(nums[K - 1])

Submission status: Accepted

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

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

print (w[-k])

Submission status: Accepted

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

count=1
num=min(ABK[0],ABK[1])+1

while count<=ABK[2]:
 count=count+1
 flag=0
 while flag==0:
  num=num-1
  if ABK[0]%num==0 and ABK[1]%num==0:
    flag=1
  
  
print(num)

Submission status: Accepted

Solution code:
A,B,C = (int(i) for i in input().split())

box=[]
for j in range(min(A,B),0,-1):
    if A % j ==0 and B % j ==0:
        box.append(j)

print(box[C-1])

Submission status: Accepted

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

a_divisors = set()
b_divisors = set()

for i in range(1, 101):
    if A % i == 0: a_divisors.add(i)
    if B % i == 0: b_divisors.add(i)

common_divisors = a_divisors & b_divisors

print(sorted(list(common_divisors))[-K])

Submission status: Accepted

Solution code:
#coding:utf-8

if __name__ == "__main__":
    A, B, K = map(int, input().split())
    L = []
    for n in range(1, min(A, B)+1):
        if A % n == 0 and B % n == 0:
            L.append(n)

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

Submission status: Accepted

Solution code:
a, b, k = list(map(int,input().split()))
def yakusu(n):
    ys = []
    for i in range(1, n+1):
        if n % i == 0:
            ys.append(i)
    return ys
ys_a = yakusu(a)
ys_b = yakusu(b)
ys_ab = list(set(ys_a)&set(ys_b))
ys_ab = sorted(ys_ab)
print(ys_ab[-k])

Submission status: Accepted

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

i=0
j=100
while i<K:
    if A%j==0 and B%j==0:
        i +=1
    else:
        i =i
    j-=1

print(j+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
	A, B, K = map(int, input().split(" "))
	
	tmp = []
	counts = 0
	for i in range(1, 101):
		if A % i == 0 and B % i == 0:
			tmp.append(i)
			counts += 1
	
	print(tmp[counts - K])
	
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
res = []
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,c=(int(x)for x in input().split())
division =[]
if a>=b:
    x=a
    while x>0:
        if a%x==0 and b%x==0:
            division.append(x)
            x -=1
        else:
            x -=1
else:
    x=b
    while x>0:
        if a%x==0 and b%x==0:
            division.append(x)
            x -=1
        else:
            x -=1

print(division[c-1])

Submission status: Accepted

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

N = min(a,b)
cd = []

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

print(cd[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
i = min(A,B)
answer = 0
while i > 1:
    if A % i == 0 and B % i == 0:
        answer += 1
        if K == answer:
            break
    i -= 1
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def int_raw():
    return int(raw_input())
 
def words_raw():
    return raw_input().split()
 
def ints_raw():
    return map(int, words_raw())

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

Submission status: Accepted

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

for m in range(100,0,-1):
  if (a%m == 0 and b%m == 0):
    anskey.append(m)
    
print(anskey[k-1])

Submission status: Accepted

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

if A > B:
    A, B = B, A

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

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

Submission status: Accepted

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


if A > B:
	A, B = B, A
	#print(A,B)

d = []

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

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

Submission status: Accepted

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


if A > B:
	tmp = B
	B = A
	A = tmp
	#print(A,B)

d = []

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

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

Submission status: Accepted

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

n = min(a, b) + 1 
while k:
    n -= 1
    if a % n == 0 and b % n == 0:
        k -= 1
print(n)

Submission status: Accepted

Solution code:
a,b, c = map(int, raw_input().split())
list_a = []
for i in range(1,101):
    if a%i == 0 and b %i ==0:
        list_a.append(i)
list_a.reverse()
print (list_a[c-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.sort(reverse = True)
print(d[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a,b):
    while a%b!=0:
        a,b=b,a%b
    return b

a,b,k=map(int,input().split(" "))
g=gcd(a,b)
if k==1:
    print(g)
else:
    cnt = 1
    for n in range(2,g+1):
        if g%n==0:
            cnt+=1
            if cnt==k:
                print(int(g/n))
                break

Submission status: Accepted

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

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 divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = int(c)-1
    print(D[q])

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

Submission status: Accepted

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

if(A > B):
    start = B
else:
    start = A

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABK=input().split()
A=int(ABK[0]);B=int(ABK[1]);K=int(ABK[2])
list=[]
for i in range(1,min(A,B)+1):
    if (A/i).is_integer() and (B/i).is_integer():
        list.append(i)
list.sort(reverse=True)
print(str(list[K-1]))

Submission status: Accepted

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

answer_candidate = []
limit = max(A, B)

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

print(answer_candidate[len(answer_candidate) - 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 == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break

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 == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
num = []
for i in range(1,101):
    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())
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:
# Common Division
Ai,Bi,K = map(int, input().strip().split())
A = max(Ai,Bi)
B = min(Ai,Bi)
x = [n for n in range(1,B+1)[::-1] if A%n == 0 and B%n == 0]
print(x[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

print(l[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
cnt = 0
ans = -1
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:
a,b,k = map(int,input().split())
division = list()

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

print(division[-k])

Submission status: Accepted

Solution code:
A, B, N = map(int, input().split())
if B < A:
  B_t = A
  A = B
  B = B_t

divisors = []
divisors_A = []

for s in range(1, A+1):
  if A % s == 0:
    divisors_A.append(s)
    
for k in divisors_A:
  if B % k == 0:
    divisors.append(k)
    
divisors = divisors[::-1]
print(divisors[N-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

A_divisor = set()
for i in range(1, A+1):
    if divmod(A,i)[1] == 0:
        A_divisor.add(i)

B_divisor = set()
for i in range(1, B+1):
    if divmod(B,i)[1] == 0:
        B_divisor.add(i)

Intersection = list(A_divisor & B_divisor)
print(sorted(Intersection, reverse=True)[C-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

max = max(a, b) + 1
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

Submission status: Accepted

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

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

max = 101
#if a < b:
#    max = a

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

Submission status: Accepted

Solution code:
class MathAlgorithm(object):

    MOD = 10000000 + 7

    @classmethod
    def gcd(cls, a: int, b: int) -> int:
        if b < 0 or (a == 0 and b == 0):
            raise ValueError

        if b > a:
            return cls.gcd(b, a)

        if b == 0:
            return 0

        if a % b == 0:
            return b

        return cls.gcd(b, a % b)


if __name__ == '__main__':
    A, B, K = map(int, input().split())

    gcd = MathAlgorithm.gcd(A, B)
    common_divides = []

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

    print(common_divides[-K])

Submission status: Accepted

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

als = []
bls = []

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

common = []

for a in als:
  if a in bls:
    common.append(a)

common.sort()
print(common[-K])

Submission status: Accepted

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

ary=[]

min_num=min(A,B)

for i in range(min_num):
    div_num=i+1
    if A%div_num == 0 and B%div_num == 0:
        ary.append(div_num)

ary.reverse()

#print ary
print ary[K-1]

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

a,b,k = na()

c =min(a,b)
d = 0
while(1):
  if a%c == 0 and b%c == 0:
    d += 1
  if d == k:
    break
  c -= 1
  
print(c)

Submission status: Accepted

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

def euclid(a, b):
    c = 1
    big = max(a, b)
    small = min(a, b)
    while (c != 0):
        c = big % small
        big = small
        small = c
    return big

c = euclid(a, b)
if k == 1:
    print(c)
    exit()
else:
    a_list = [i for i in range(1,c) if (c%i == 0)]
    print(a_list[-k+1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
a=[]
#b=[]
if A>=B:
  for i in range(1, A+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( i )
      # b.append( B/i )
  
else:
  for i in range(1, B+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( i )
      # b.append( B/i )

#print(a)
#print(b)

#c=[]
#for ea in a:
 # if ea in b:
  #  c.append( ea )
c=len(a)
print(a[c-K])

Submission status: Accepted

Solution code:
num_A, num_B, order_K = map(int, raw_input().split())

def get_divisor(num):
  results_divisor = []
  for i in range(1, num + 1):
    if num % i == 0:
      results_divisor.append(i)
  return results_divisor

common_divisor =  list(set(get_divisor(num_A)) &  set(get_divisor(num_B)))
common_divisor.sort(reverse=True)
print common_divisor[order_K - 1]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m
a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
for i in range(g+1)[::-1]:
    if i==0:
        break
    if g%i==0:
        cd.append(i)
print(cd[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def euclid(p,q):
  if q == 0:
    return p
  else:
    return euclid(q,p%q)
  
n = euclid(a,b)
count = 0
for i in range(n):
  if n % (n-i)==0:
    count += 1
  if count == k:
    print(n-i)
    break

Submission status: Accepted

Solution code:
a, b, k = (int(i) for i in input().split())
x = []
c = max(a, b)
for i in  range(1, c+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(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,c = (int(x) for x in input().split())
for i in range(100,0,-1):
    if a % i == 0 and b % i == 0:
        c -= 1
        if c == 0:
            print(i)

Submission status: Accepted

Solution code:
def gcd(a, b, k):
    count = 0
    if a < b:
        a, b = b, a
    for i in range(1,b+1)[::-1]:
        if a % i == 0 and b % i == 0:
            count += 1
            if count == k:
                return i

li = list(map(int, input().split()))
print(gcd(li[0], li[1], li[2]))

Submission status: Accepted

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

n = min(A,B)
l = []

for x in range(1,n+1):
    if A%x == 0 and B%x==0:
        l.append(x)

l.sort(reverse=True)

print(l[K-1])

Submission status: Accepted

Solution code:
a,b,k=[int(item) for item in 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)
    break

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in input().split(" ")]
c = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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