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

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
A_box = []
B_box = []
for i in range (1,101):
    if (A/i) == int(A/i):
        A_box.append(i)
    if (B/i) == int(B/i):
        B_box.append(i)
result=list(set(A_box) & set(B_box))
result.sort()

print(result[-K])

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8

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

Submission status: Accepted

Solution code:
import fractions
li = list(map(int,input().split()))
a=li[0]
b=li[1]
k=li[2]
saidai=fractions.gcd(a,b)
yakusuu=[]
for i in range(100):
    if saidai%(i+1)==0:
        yakusuu.append(i+1)
yakusuu.sort()
yakusuu.reverse()
print(yakusuu[k-1])

Submission status: Accepted

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

Submission status: Accepted

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


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

A_yaku=set(yaku(A))
B_yaku=set(yaku(B))
# print(A_yaku)
# print(B_yaku)

yakusu=list(A_yaku & B_yaku)
# print(yakusu[K-1])
yakusu.sort(reverse=True)
print(yakusu[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
x = 0
i = 0
ans = [0] * 100
while i < max(A, B, 100):
    i += 1
    if ((A % i) == 0) and ((B % i) == 0):
        ans[x] = i
        x += 1
print(ans[x - K])

Submission status: Accepted

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

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

Submission status: Accepted

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

max_num = max(A, B)
count = 0

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

Submission status: Accepted

Solution code:

def main():
    a = list(map(int, input().split()))
    count = 0
    data_list = [i for i in range(1, a[0] + 1)]
    for i in data_list[::-1]:
        if a[0] % i == 0 and a[1] % i == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
mi=min(a,b)
ma=max(a,b)
flag=0
nim=0
ans=0

while True:
    tmp = mi - nim
    if flag == k:
        break
    else:
        if ma%tmp == 0:
            if mi%tmp == 0:
                ans = tmp
                nim += 1
                flag += 1
            else:
                nim += 1
        else:
            nim += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inData = input().split(' ')

seisu1 = int(inData[0])
seisu2 = int(inData[1])
ansK = int(inData[2])
ansList = []
maxSeisu = min([seisu1, seisu2])

for i in range(1, maxSeisu + 1):
    if (seisu1 % i == 0) and (seisu2 % i == 0):
        ansList.append(i)

ansListLen = len(ansList)
print(ansList[ansListLen - ansK])

Submission status: Accepted

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

tmp = input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
k = int(tmp.split(" ")[2])

x = int(min(a,b))
i= int(0)

while i < k:
    if a%x ==0:
        if b%x==0:
            i = i+1
            x = x-1
        else:
            x = x-1
    else:
        x = x-1
x=x+1
print(x)

Submission status: Accepted

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

if A==1 or B==1:
    print(1)
else:
    div = [x for x in range(1, min(A,B)+1) if A%x==0 and B%x==0]
    print(div[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
if(A > B):
    A,B = B,A
d = 1;
l = []
while(d*d <= A):
    if(A%d != 0):
        d += 1
        continue
    if(not (B%d)):
        l.append(d)
    if(A//d != d and not (B%(A//d))):
        l.append(A//d)
    d += 1
l.sort(reverse=True)
print(l[K-1])

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
A, B, K = 0, 0, 0


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


def main():
    set_inputs()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

#print(a_list)
for j in range(1, B+1):
    #print(j)
    if B % j == 0:
        b_list.append(j)
#print(b_list)
a_b_list = list(set(a_list) & set(b_list))
a_b_list.sort(reverse=True)
#print(a_b_list)
print(a_b_list[K-1])

Submission status: Accepted

Solution code:
a, b, k = (int(i) for i in input().split())
a_list = []
b_list = []
for i in range(1, a+1):
  if a % i == 0:
    a_list.append(i)
for i in range(1, b+1):
  if b % i == 0:
    b_list.append(i)
list1 = list(set(a_list) & set(b_list))
list2 = sorted(list1, reverse=True)
print(list2[k-1])

Submission status: Accepted

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

for i in range(100,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 = 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)
l = l[::-1]
print(l[k - 1])

Submission status: Accepted

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

Submission status: Accepted

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

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

a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])

Submission status: Accepted

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

x = max(a, b)
y = min(a, b)
gcd = 0
if x % y == 0:
    gcd = y
else:
    while x % y != 0:
        z = x % y
        x = y
        y = z
    else:
        gcd = z

list_gcd = list()

for i in range(1, int(gcd/2) + 1):
    if gcd % i == 0:
        list_gcd.append(i)

list_gcd.append(gcd)
print(list_gcd[-k])

Submission status: Accepted

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

	result = retDivs(a,b)
	print(result[len(result)-k])
def retDivs(a, b):
	n = 0
	ret = []
	for x in range(1,max(a, b)+1):
		if a%x == 0 and b%x == 0:
			ret.append(x)
	
	return ret



if __name__ == "__main__":
	main()

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=list(map(int,input().split()))

L=[]

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

print(L[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
      d.append(num)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = sorted(list(d),reverse=True)
print(d[C-1])

Submission status: Accepted

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

a=int(a)
b=int(b)
k=int(k)

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

list=divisor(a)+divisor(b)
s_list=sorted(list)[::-1]

c=0
for i, s in enumerate(s_list[:-1]):
    if s_list[i] == s_list[i+1]:
        c+=1
        if c==k:
            print(s)

Submission status: Accepted

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

print(res[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    more = a if a > b else b

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

    number_list.sort(reverse=True)
    print(number_list.pop(k - 1))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

A, B, K = [int(s) for s in input().split(' ')]
gcd = find_gcd(A, B)
if K == 1:
    print(gcd)
else:
    for i in range(gcd // 2, 0, -1):
        if gcd % i == 0:
            K -= 1
        if K == 1:
            break
    print(i)

Submission status: Accepted

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

d=[]
for yai in y_a:
  if yai in y_b:
    d.append(yai)
print(d[-k])

Submission status: Accepted

Solution code:
from fractions import gcd

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

d = gcd(A, B)

def divisor(n):
    #for i in range(1,int(n**0.5)+1):
    ass = [i for i in range(1, n+1) if n % i == 0]
    return ass

ass = divisor(d)
#print(ass)
out = ass[-K]
print(out)

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)

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

Submission status: Accepted

Solution code:
i = input().split(" ")
a, b, k = int(i[0]), int(i[1]), int(i[2])

list = []
n = -1
for x in range(1, 101):
    if a%x == 0 and b%x == 0:
        list.append(x)
        n += 1

print(list[n-k+1])

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

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
        return divisor_list
C=gcd(A,B)
D=make_divisor_list(C)
D.sort()
D.reverse()
print(D[K-1])

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

Submission status: Accepted

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

lst = []
for i in range(1, a+1):
  if a % i == 0:
    lst.append(i)
lst.sort(reverse=True)
cnt = 0
for num in lst:
  if b % num == 0:
    cnt += 1
    if cnt == k:
      print(num)
      break

Submission status: Accepted

Solution code:
from sys import stdin
import sys

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

a, b, k = list(map(int, stdin.readline().rstrip().split()))
g = gcd(a,b)

cnt = 0
l = []
for i in range(g // 2):
	if g % (i+1) == 0:
		l.append(i+1)

l.append(g)
print(l[len(l)-k])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=101
k=0
while k!=c:
    l-=1
    if a%l==0 and b%l==0:
        k+=1
    
print(l)

Submission status: Accepted

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

A = []

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



print(A[len(A)  - c])

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
i = min(a, b)
while i > 0:
    if (a % i == 0) and (b % i == 0):
        count += 1
    if count == k:
        break
    i -= 1

print(i)

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())
lst = []
for i in range(1 , min(A , B) + 1):
    if A % i == 0 and B % i == 0:
        lst.append(i)
print(lst[-K])

Submission status: Accepted

Solution code:
import fractions as f
a,b,k=map(int,input().split())
g=f.gcd(a,b)
count=0
#print(g)
for s in range(g,0,-1):
    if g%s==0:
  #      print(s)
        count+=1
    if count==k:
        print(s)
        exit()

Submission status: Accepted

Solution code:
import fractions

A, B, K = [int(_) for _ in input().split()]
g = fractions.gcd(A, B)

cnt = 1
for i in range(g, 0, -1):
    if g % i == 0:
        if cnt == K:
            print(i)
            break
        else:
            cnt += 1

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

Submission status: Accepted

Solution code:
import fractions

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

gcd = fractions.gcd(A, B)
order = 0
for i in range(gcd, 0, -1):
    if gcd % i == 0:
        order += 1
        if order == K:
            print(i)
            break

Submission status: Accepted

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

num = 0
for x in reversed(range(1, 101)):
    d = a % x + b % x
    if d == 0:
        num += 1
        if num == k:
            print (x)
            break

Submission status: Accepted

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

d = 1
i = 0
m = A if A < B else B
t = []
while d <= m:
    if (A % d == 0) and (B % d == 0):
        t.append(d)

    d += 1
    

r = t[len(t) - K]
print(r)

Submission status: Accepted

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

count = 0
for i in reversed(range(1, max(A, B) + 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 = [int(x) for x in input().split()]
list_ = []
for k in range(1, min(A,B)+1):
  if A % k == 0 and B % k == 0:
    list_.append(k)
print(list_[::-1][K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = (int(i) for i in input().split())
counter = 0
i=min(a,b)+1
while counter != k:
    i-=1
    if a%i==0 and b%i==0:
        counter+=1
print(i)

Submission status: Accepted

Solution code:
a,b,k = (int(i) for i in input().split())
l = []
for i in range(1,101):
  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 = map(int, input().split())
cnt = 0
for i in range(100, 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())

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random


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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions

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

c = fractions.gcd(a,b)
d = []

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

print(d[-k])

Submission status: Accepted

Solution code:
# coding: utf-8

def _main():
    text = input()
    A, B, K = [int(i) for i in text.split(' ')]

    diviser_list = []
    num = 1
    min_num = min(A, B)

    while num <= min_num:
        if A%num == 0 and B%num == 0:
            diviser_list.append(num)

        num += 1

    print(diviser_list[-K])

if __name__ == '__main__':
    _main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
in_str = input()
input_list = list(map(int,in_str.split()))
A = input_list[0]
B = input_list[1]
K = input_list[2]
count = 0
ans = 0
max = 100
for i in range(max):
  div = max-i
  if(A%div==0 and B%div==0):
    ans = div
    count+=1
    if(count==K):
      break
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

count = 1
for i in xrange(100, 0, -1):
    if i == 0: continue
    if A % i == 0 and B % i == 0:
        if count == K:
            print str(i)
            break
        count += 1

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def euclid(a,b):
    if b % a == 0:
        return a 
    else:
        return euclid(b % a, a)
#aもbも割り切る正の整数のうちK番目に大きいもの
#最大公約数の約数のうちK番目に大きいものを求めればよいでしょう
a,b,k = map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input().split()
A = int(a[0])
B = int(a[1])
K = int(a[2])
cd = []
i = 1
if A < B:
    big = B
else:
    big = A
while i <= big:
    if A % i == 0 | B % i == 0:
        cd.append(i)
    i += 1

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

Submission status: Accepted

Solution code:
def main():
    A, B, K = [int(_) for _ in input().split()]
    
    l = 0
    for i in range(A):
        #print(B % (A-i-1))
        #exit()
        if A % (A-i) == 0 and B % (A-i) == 0:
            #print("A")
            l = l + 1
            #print(l)
            if l == K:
                print(A-i)
                exit()
    
main()

Submission status: Accepted

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

print(box[-K])

Submission status: Accepted

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

a,b,k = map(int,input().split())
x = gcd(a,b)
list_num = []
for i in range(1,x+1):
    if x % i == 0:
        list_num.append(i)
list_num = sorted(list_num,reverse=True)
print(list_num[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
a, b, k = map(int, input().split())
max_yakusuu = gcd(a, b)
yakusuu_array = []
for i in range(1,max_yakusuu):
  if max_yakusuu % i == 0:
    yakusuu_array.append(i)
if k!=1:
  print(yakusuu_array[len(yakusuu_array)-k+1])
else:
  print(max_yakusuu)

Submission status: Accepted

Solution code:
from math import floor


def main():
    A, B, K = map(int, input().split())
    # 1 is always divisor for integer
    divisors = [1]
    for d in range(2, min(A, B)+1):
        if (B % d == 0 and A % d == 0):
            divisors.append(d)
    print(divisors[-K])


main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

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

count = 0


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

Submission status: Accepted

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

l = []
n = 0
while(b != n):
    n += 1
    if (a % n == 0 and b % n == 0):
        l.append(n)

print(l[-k])

Submission status: Accepted

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

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)
common = list(set(A) & set(B))
common.sort(reverse=True)

print(common[k-1])

Submission status: Accepted

Solution code:
def main():
    A, B, K = map(int, input().split())
    i = 0
    v = []
    while min(A, B) > i:
        i += 1
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K])


main()

Submission status: Accepted

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

cnt = 0
ans_dic = {}
for i in range(max(a, b)):
    n = i+1
    if a%n == 0 and b%n == 0:
        cnt += 1
        ans_dic[cnt] = n

print(ans_dic[cnt - (k-1)])

Submission status: Accepted

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

Submission status: Accepted

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

b = int(a[0])
c = int(a[1])
d = int(a[2])
count = []

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

print(count[-d])

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(1,a+1):
    if a % i == 0:
        a_list.append(i)
for i in range(1,b+1):
    if b % i == 0:
        b_list.append(i)
print(sorted(list(set(a_list) & set(b_list)))[::-1][k-1])

Submission status: Accepted

Solution code:
#ABC120B-K-thCommonDivisor.py

from sys import stdin

input = stdin.readline

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

commonDivisor = []

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

print(commonDivisor[-K])

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 = (int(i) for i in input().split())

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

Submission status: Accepted

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

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

print(yakusu_list[K-1])

Submission status: Accepted

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

tmp = 0

for i in range(101,0,-1):
    if a % i ==0 and b % i ==0:
        tmp += 1
        if tmp == 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)
    else:
        pass
anslength = len(ans)
print(ans[anslength-k])

Submission status: Accepted

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

li = []
s = 1
e = 0
a = float(a)
b = float(b)

while True:
    if a % s == 0 and b % s == 0:
        li.append(s)
        e += 1
    if s == a or s == b:
        break
    s += 1

print(li[-k])

Submission status: Accepted

Solution code:
import math
Alist = []
Blsit = []
yakusuu = []
A,B,K = map(int,input().split())
Alist = [i for i in range(1,A+1) if A%i==0]
Blist= [i for i in range(1,B+1) if B%i==0]
for a in Alist:
    for b in Blist:
        if a==b:
            yakusuu.append(a)
yakusuu.sort()
print(yakusuu[-K])

Submission status: Accepted

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

i = 100
j = 1

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

Submission status: Accepted

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

def main():
    sp = [int(e) for e in input().split(" ")]
    a = sp[0]
    b = sp[1]
    k = sp[2]

    big = max(a, b)

    idx = 1
    for i in range(big):
        if a%(big-i) == 0 and b%(big-i) == 0:
            if idx == k:
                print(big-i)
            idx+=1

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
count=0
k=0
c=[]
while k!=max(A,B):
    k+=1
    if A%k==0 and B%k==0:
        count+=1
        c.append(k)

print(c[-K])

Submission status: Accepted

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

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