Problem:


Score : 200 points

Problem Statement

You are given positive integers A and B.

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

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

1 \leq A, B \leq 100

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

K \geq 1

Input

Input is given from Standard Input in the following format:

A B K

Output

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

Sample Input 1

8 12 2

Sample Output 1

2

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

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1



Sample input:
8 12 2


Sample output:
2

Submission status: Accepted

Solution code:
def main():
    a,b,k = list(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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(cdlist[-K])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
res = []
for i in range(1, max(a,b) +1):

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

# 出力
ans = [n for n in range(A, 0, -1) if A % n == B % n == 0][K - 1]
print(ans)

Submission status: Accepted

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

# 出力
ans = [n for n in range(max(A, B), 0, -1) if A % n == B % n == 0][K - 1]
print(ans)

Submission status: Accepted

Solution code:
A, B, K = [int(akb) for akb in input().split()]
a, b = min(A, B), max(A, B)
r = b % a
while r > 0:
  b = a
  a = r
  r = b % a
gcd = a
ans = a
if K > 1:
  for i in range(1, 100):
    if gcd % (i+1) == 0:
      ans = gcd / (i+1)
      K -= 1
    if K == 1:
      break
print(int(ans))

Submission status: Accepted

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


def solve(A: int, B: int, K: int):
    cnt = 0
    
    mab = max(A,B)
    for i in range(mab,0,-1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            print(i)
            break




# Generated by 1.1.4 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:
import fractions

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions

# スペース区切りの整数の入力
A,B,K = map(int, input().split())

divisor = fractions.gcd(A,B)
counter = 1

if K==1:
  print(divisor)
  
else:
  divisor-=1
  while(divisor>=0):
    #print(divisor)
    
    if A%divisor==0 and B%divisor==0:
      counter+=1
      #print("count",counter)
      
      if counter==K:
        break
        
    divisor-=1
    
  print(divisor)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

tmp = max(A,B)

ans = []
for i in range(tmp+1):
    if i > 0:
        if A % i == 0 and B % i == 0:
            ans.append(i)

ans.reverse()

print(ans[K-1])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
i=1
ans=[]
n=min(A,B)

while i<=n:
       if A%i==0 and B%i==0:
              ans.append(i)
       i+=1

print(ans[-K])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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())
cnt = 0
for i in range(100,0,-1):
  if A % i == 0 and B % i == 0:
    cnt += 1
    if cnt == K:
      print(i)
      break

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
sp = stdin.readline().split()
A,B,K = int(sp[0]), int(sp[1]), int(sp[2])
def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l

al = set(div(A))
bl = set(div(B))
ans = list(al & bl)
ans = sorted(ans)
ans.reverse()
print(ans[K-1])

Submission status: Accepted

Solution code:
A, B, K = [int(i) for i in input().split()]
th = []
i = 0
while True:
    i += 1
    if (A % i, B % i) == (0, 0):
        th.append(i)
    if i > A or i > B:
        break
print(th[len(th) - K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
n_list = list(range(min(A,B)))
n_list.reverse()
n_list = [1+i for i in n_list]
c = 0

for n in n_list:
    if A%n == 0 and B%n == 0:
        c += 1
    if c == K:
        print(n)
        break

Submission status: Accepted

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

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

print(l[k-1])

Submission status: Accepted

Solution code:
def solve(A, B, K):
    yakusu = list()
    for i in range(1, 101):
        if A % i == 0 and B % i == 0:
            yakusu.append(i)
    return yakusu[-K]


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

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

A,B,K = inpl()
tmp = max(A,B)+1
k = 0
while k < K:
    tmp -= 1
    if A%tmp == 0 and B%tmp == 0:
        k += 1
        
print(tmp)

Submission status: Accepted

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

if A > B:
  N = A
else :
  N = B

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

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

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

max = 0
if A > B:
    max = A
else:
    max = B

for i in range(1, max + 1):
    if A % i == 0 and B % i == 0:
        list.insert(0, i)

print(list[K - 1])

Submission status: Accepted

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

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

print(divisors[-K])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 18:58:31 2019

@author: avina
"""

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

        ith += 1

Submission status: Accepted

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

Submission status: Accepted

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

check = []
for i in range(10**5):
    num += 1
    if A % num == 0 and B % num == 0:
        check.append(num)

print(check[-K])

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    x = [x for x in range(1, min(A, B) + 1) if A % x == 0 and B % x == 0]
    print(sorted(x, reverse=True)[K - 1])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

# solve
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=map(int,input().split())
ans = list()
for i in range(1,10001):
    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())
l = []
for i in range(1, 101):
  if a%i == 0 and b%i == 0:
    l.append(i)
l.sort(reverse=1)
print(l[k-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
cnt = 0
num = min(A, B)

while num >= 1:
    if A % num == 0 and B % num == 0:
        cnt += 1
        if cnt == K:
            break
    num -= 1

print(num)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
cnt = 0
num = min(A, B)

while cnt < K:
    if A % num == 0 and B % num == 0:
        cnt += 1
        if cnt == K:
            break
    num -= 1

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def divisor_list(n):
    """n の正の約数のリスト"""
    ret = []
    for k in range(1, int(n**0.5) + 1):
        if n % k == 0:
            ret.append(k)
            if k != n // k:
                ret.append(n // k)
    return list(sorted(ret, reverse=True))


print(divisor_list(gcd(A, B))[K - 1])

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)

Submission status: Accepted

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

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

    divisors.sort()
    return divisors

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

gcd_num = gcd(A,B)

divisor = make_divisors(gcd_num)

print(divisor[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

import sys
input = sys.stdin.readline

def f(n):
    l = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            l.add(i)
            l.add(n // i)
            
    return l

a, b, c = map(int, input().split())
l = list(f(a) & f(b))
l.sort()
print(l[0 - c])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

r = B % A;
ans = [];

while(r != 0):
	B = A;
	A = r;
	r = B % A;

for i in range(1,A+1):
	if A%i == 0:
		ans.append(i);
print(ans[-K]);

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions as frac

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

cd_list = []
for i in range(1,max(A,B)+1) :
    if (A % i == 0 and B % i == 0) :
        cd_list.append(i)
        # if (len(cd_list) >= K) :
        #     break

print(cd_list[-K])

Submission status: Accepted

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

Submission status: Accepted

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

def f(A,B,K):
  k=0
  for m in range(euk(A,B), 0, -1):
    if A%m == 0 and B%m == 0:
      k+=1
    if k==K:
      return m

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

Submission status: Accepted

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

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)

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

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
cnt = 0
l = []
for i in range(max(A+1,B+1),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())

# A, B, K = [8, 12, 2]
# A, B, K = [100, 50, 4]
# A, B, K = [1, 1, 1]

ans = []

for i in range(min(A, B)+1, 0, -1):
    if (A % i == 0) and (B % i == 0):
        ans.append(i)
        if len(ans) == K:
            break

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

Submission status: Accepted

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

# A, B, K = [8, 12, 2]
# A, B, K = [100, 50, 4]
# A, B, K = [1, 1, 1]

ans = [1]

for i in range(2, 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())
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)
 
print(sorted(list(a & b), reverse = True)[K - 1])

Submission status: Accepted

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

n = 0
if a < b:
  n = a
else:
  n = b

cd_list = []
i = 1
while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

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

Submission status: Accepted

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

    return divisors


A, B, K = map(int, input().split())
divisors_all = make_divisors(A) + make_divisors(B)
divisors = sorted([i for i in set(divisors_all)
                   if divisors_all.count(i) == 2], reverse=True)
print(divisors[K - 1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
counter = 0
for i in range(100, 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())

ans = []
i = A if (A >= B) else B
while(1):
  if (A % i == 0 and B % i == 0):
    ans.append(i)
  i -=1
  if (len(ans) == K):
    break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions as f
a,b,k = (int(j) for j in input().split())
c = f.gcd(a,b)
count = 1
d = c
while count < k:
    d = d - 1
    if c % d == 0:
        count = count + 1
print(d)

Submission status: Accepted

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

mini = min(A, B)
a = range(1, mini+1)
a = {i for i in a for j in a[::-1] if i * j == mini}

maxi = max(A, B)
b = range(1, maxi+1)
b = {i for i in b for j in b[::-1] if i * j == maxi}

print(sorted(a & b, reverse=True)[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(hoge[-K])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

    print(answer)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
lists=[]
x=max(a,b)
while len(lists)<k:
      if a%x==0==b%x:
            lists.append(x)
            x-=1
      else:
            x-=1
print(lists[k-1])
#print(lists)

Submission status: Accepted

Solution code:
def cd(a,b):
  p = min(a,b)
  q = max(a,b)
  lst = []
  for i in range(1, p + 1):
    if (p % i == 0 and q % i == 0):
      lst.append(i)
  return lst
 
A,B,K = map(int, input().split())
lst = cd(A,B)
print(lst[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


# Generated by 1.1.4 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=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)+1):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
a, b, k = map(int, input().split())

_gcd = gcd(a, b)

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

Submission status: Accepted

Solution code:
from fractions import gcd
A,B,K = [int(a) for a in input().split(" ")]
val = gcd(A, B)
cnt = 1
while cnt<K and val>=0:
    val-=1
    if A%val==0 and B%val==0:
        cnt+=1
print(val)

Submission status: Accepted

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

A,B,K=map(int,input().split())
gcdAB=gcd(A, B)
cnt=0
for i in range(gcdAB):
    n=gcdAB-i
    if gcdAB%n==0:
        cnt=cnt+1
    if cnt==K:
        print(n)
        exit()

Submission status: Accepted

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

def gcd(a,b):
  if b>a:
    a,b=b,a

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

first=gcd(A,B)
if first==1:
  print(1)
else:
  k=1
  if K==1:
    print(first)
  else:
    for i in reversed(range(1,first)):
      if A%i==0:
        if B%i==0:
          k=k+1
          if k==K:
            print(i)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in 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())
m=min(a,b)
n=m
cnt=1
while cnt <= k:
 if a % n == 0 and b % n == 0:
  cnt=cnt+1
  n=n-1
 else:
  n=n-1
print(n+1)

Submission status: Accepted

Solution code:
# coding: utf-8

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

l = []
x = min(a,b)
for i in range(1,x+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())
c=0
p=min(a,b)
while (c!=k):
	if a%p==0 and b%p==0:
		x=p
		c+=1
	p-=1
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans_ary[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L=input().split()
A=int(L[0])
B=int(L[1])
K=int(L[2])
Key=[]

cnt=0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
a,b,k=map(int,input().split())
c=0
for i in range(max(a,b),-1,-1):
  if (a%i)==0 and(b%i)==0:
    c+=1
    if c==k:
      print(i)
      exit()

Submission status: Accepted

Solution code:
import fractions

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

a_re = []
b_re = []

for i in range(max(A,B) + 1):
    if i == 0:
        continue
    #print(i)
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)
#print(a_re)

result = list (set(a_re) & set( b_re))

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

Submission status: Accepted

Solution code:
from fractions import gcd
from math import sqrt, ceil
A, B, K = map(int, input().split())
c = gcd(A, B)
res = 0
count = 0

for i in reversed(range(1,c + 1)):
    if c % i == 0:
        count += 1
        if count == K:
            print(i)
            break

Submission status: Accepted

Solution code:
[A,B,K] = [int(i) for i in input().split()]
def make_gcd(a,b):
    while b:
        a,b = b,a%b
    return a
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 = sorted(divisors,reverse=True)
    return divisors
gcd = make_gcd(A,B)
print(make_divisors(gcd)[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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



if __name__ == "__main__":
    solve()

Submission status: Accepted

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

ans = 0
ans_k = 0

n = min(a, b)

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

print(ans)

Submission status: Accepted

Solution code:
import fractions

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

gcd=fractions.gcd(a,b)
cd_list=[]
for i in range(1,gcd+1):
    if gcd%i==0:
        cd_list.append(gcd/i)
ans=int(cd_list[k-1])
print(ans)

Submission status: Accepted

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

import fractions
g=fractions.gcd(a,b)

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

print(c[-k])

Submission status: Accepted

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

for i in reversed(range(max(a, b)+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())
count = []

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

print(count[-k])

Submission status: Accepted

Solution code:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = [1]
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
        return divisor_list


a = make_divisor_list(A)
b = make_divisor_list(B)
c = set(a) & set(b)
c = sorted(list(c), reverse=True)

print(c[K - 1])

Submission status: Accepted

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

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

print(count[-k])

Submission status: Accepted

Solution code:
import math

input = input().split()

intInput = [int(i) for i in input]

division = min(intInput[0],intInput[1])

list=[1]

for i in range(2, division+1):
	if intInput[0] % i == 0 and intInput[1] % i == 0:
		list.append(i)

print(list[len(list)-intInput[2]])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def s(n):
    ls=[]
    for i in range(1,n+1):
        if n%i==0:
            ls.append(i)
    return ls

ans=[]
a,b,k=map(int,input().split())
for i in s(a):
    if i in s(b):
        ans.append(i)

print(ans[-k])