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=(int(i) for i in input().split())
#print(a,b,k)
cnt=0
x=min(a,b)
for i in range(x,0,-1):
  if a%i==0 and b%i==0:
    cnt+=1
    if cnt==k:
      print(i)
      cnt+=1

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

Submission status: Accepted

Solution code:
import math
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[len(d)-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)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,k = LI()
    c = 0
    for i in range(min(a,b),0,-1):
        if a % i == 0 and b % i == 0:
            c += 1
            if c == k:
                return i

    return -1



print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=[int(i) for i in input().split()]
ans=[]
i=1
while True:
    if i>min(a,b):
        break
    if (a%i==0) and (b%i==0):
        ans.append(i)
    i+=1
print(ans[len(ans)-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())
d=[]
if(A>B):
    M=A
    m=B
else:
    M=B
    m=A

for x in range(m,0,-1):
    if(m%x ==0 and M%x ==0):
       d.append(x) 

print(d[K-1])

Submission status: Accepted

Solution code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B

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

Submission status: Accepted

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

Submission status: Accepted

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

def func(m,n):
	x = max(m,n)
	y = min(m,n)
	tmp =[]
	for it in range(y):
		it = it + 1
		if x%it == 0 and y%it==0:
			tmp.append(it)
	return tmp

tmp = func(a,b)
print(tmp[len(tmp)-K])

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
ab=[i for i in range(1,101) if a%i==0 and a/i>0]+[i for i in range(1,101) if b%i==0 and b/i>0]
AB=[i for i in set(ab) if ab.count(i)>1]
AB.sort(reverse=True)
print(AB[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
A,B,K = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())

i = 1
cnt = 1
factor = [0]*100
for i in range(1,101):
    if(A%i == 0 and B%i == 0):
        factor.append(i)
factor = sorted(factor)
print(factor[-K])

Submission status: Accepted

Solution code:
#abc120b

a,b,k=map(int,raw_input().split())
l=[]
for i in xrange(1,min(a,b)+1):
 if a%i==0 and b%i==0:
  l.append(i)
print l[-k]

Submission status: Accepted

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

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:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i>0):
    
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

Submission status: Accepted

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

X = []
cnt = 0
for i in range(1, 1 + int(min(list[0],list[1]))):
  if(list[0] % i == 0 and list[1] % i == 0):
    X.append(i)
    cnt = 1
X.sort(reverse=True)
if (cnt == 1):
  print(X[list[2]-1])
else:
  print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
ls.reverse()
answer = ls[K-1]
print(answer)

Submission status: Accepted

Solution code:
import scipy as sp


def divisor(num):
    list = set()
    for i in sp.arange(1, num+1):
        if num % i == 0:
            list.add(i)
    return list


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

div_a = divisor(a)
div_b = divisor(b)

cd = sp.sort(list(div_a & div_b))
cd_r = cd[::-1]
print(cd_r[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 == 0 + b % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R

def get_list_divisor(N, reverse=True):
    try:
        F = get_prime_factorized(N)
        L = re_func_divisior(F)
        R = []
        for l in L:
            for i, x in enumerate(l):
                if i == 0:
                    r = x
                else:
                    r *= x
            R.append(r)
        R.sort()
        if reverse == True:
            R.reverse()
    except:
        if N == 1:
            R = [1]
        else:
            R = [N]
    return R

def re_func_divisior(F):
    b, e = F.pop()
    P = re_func_divisior(F) if F else [[]]
    Q = [[b ** k] for k in range(e + 1)]
    return [p + q for p in P for q in Q]


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

R = set(get_list_divisor(A)) & set(get_list_divisor(B))
R = list(R)

R.sort()

print(R[-1*K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = (int(x) for x in 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 == c:
            print (i)

Submission status: Accepted

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

l=[]

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

Submission status: Accepted

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

array = [i for i in range(1, 101) if a % i + b % i < 1]
print(array[-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:
    ans = i
    break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
memo = []

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

Submission status: Accepted

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

def solve():
    A,B,K = map(int, input().split())
    n = gcd(A,B)
    for i in range(n,0,-1):
        if n % i == 0:
            K -= 1
            if K == 0:
                return i

ans = solve()
print(ans)

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("{}".format(int(i)))
            break

Submission status: Accepted

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

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

print(listQ[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
 
a, b, k = [int(i) for i in input().split()]
 
divs = []
 
for i in range(1, a+1):
    if(a % i == 0 and b % i == 0):
        divs.append(i)
 
print(divs[-k])

Submission status: Accepted

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

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

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

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 + B%i) == 0:
        l.append(i)
    else:
        pass
print(l[-K])

Submission status: Accepted

Solution code:
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
A,B,K=map(int,input().split())
G=gcd(A,B)
L=[]
i=1
while(i*i<=G):
    if G%i==0:
        L.append(i)
    i+=1
X=set()
for i in L:
    X.add(i)
    X.add(G//i)
X=sorted(list(X))
print(X[-K])

Submission status: Accepted

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

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)


plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]

l_duplicate.sort(reverse=True)

print(l_duplicate[int(data[2])-1])

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

Submission status: Accepted

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

Submission status: Accepted

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

if a > b:
	c = b
else:
	c = a

cnt = 0

while(1):
	if(a % c == 0) & (b % c == 0):
		cnt += 1

	if(cnt == k):
		print(c)
		exit()

	c -= 1

Submission status: Accepted

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

A = int(inp[0])
B = int(inp[1])
K = int(inp[2])

ans = []

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

# 降順ソート
ans.sort(reverse = True)

print(ans[K - 1])

Submission status: Accepted

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

i = 100
c = 0
while 1:
    if A % i == 0 and B % i == 0:
        c += 1
        if c == K:
            result = i
            break
    i -= 1

print(result)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
c=i=0
l=[]
while i<min(a,b):
    while i<min(a,b)and(a%-~i or b%-~i):
        i+=1
    i+=1
    if a%i<1and b%i<1:
        l.append(i)
print(l[-k])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
A, B, K = map(int, input().split())
if A > B:
    A, B = B, A
c = 0
for i in range(1, B + 1)[::-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())
print([x for x in range(max(a, b), 0, -1) if a % x == 0 and b % x == 0][k-1])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while i<=a or i<=b:
    if a%i==0 and b%i==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

nums = []
cnt = 0

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

print(nums[-K])

Submission status: Accepted

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

t=[]
for i in range(1, min(a,b)+1):
    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:
import sys
A,B,K = map(int, input().split())

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

Submission status: Accepted

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

for i in range(min(a, b), 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())
list1 = [1]
r = min(a,b)
def do():
    for i in range(2,r + 1):
        if a % i ==0 and b % i == 0:
            list1.append(i)
    print(list1[-k])
do()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,k = map(int, input().split())
l=[]
for i in range(1,min(a,b)+1):
  if a%i == 0 and b%i == 0:
    l.append(i)
print(l[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
a=[n for n in range(1,A+1) if A%n==0]
b=[n for n in range(1,B+1) if B%n==0]
print(sorted(set(a)&set(b))[::-1][K-1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
n = max(A, B)
k = 0
while True:
    if A % n == 0 and B % n == 0:
        k = k + 1
    if k >= K:
        break
    n = n - 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    count = 0

    if max(A, B) == 1:
        print 1
        return

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

num = len(l)

print(l[num-k])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
L=[]
for i in range(1,A+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())
tar=[1]
r=min(a,b)
for i in range(2,r+1):
    if a%i==0 and b%i==0:
        tar.append(i)
print(tar[-k])

Submission status: Accepted

Solution code:
A,B,K=map(int,raw_input().split());print[i for i in range(A,0,-1)if 1>A%i+B%i][K-1]

Submission status: Accepted

Solution code:
a, b, c = 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==c:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import io
import math

datalist = input().split()

data_a = int(datalist[0])
data_b = int(datalist[1])
data_k = int(datalist[2])

check_flag = 0
for i in range(data_b,0,-1):
    if data_a % i == 0 and data_b % i == 0:
        check_flag += 1
        if check_flag == data_k:
            print(i)
            sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest120-B
#  https://atcoder.jp/contests/abc120/tasks/abc120_b

def kthCommonDivisor(A,B,count):
	startNumber = min(A,B)
	canCommonDivisor = list()
	for i in range(startNumber,0,-1):
		if A % i == 0 and B % i == 0:
			canCommonDivisor.append(i)
	answer = canCommonDivisor[count-1]
	return answer

if __name__ == '__main__':
	A,B,K = map(int,input().strip().split(' '))
	solution = kthCommonDivisor(A,B,K)
	print("{}".format(solution))

Submission status: Accepted

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

A,B,K=spaceinput()

res=[]

for k in range(1,min(A,B)+1):
    if A%k==0 and B%k==0:
        res.append(k)
    
print(res[-K])

Submission status: Accepted

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

Submission status: Accepted

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

yakusuu_array = []

for ab in [a,b]:
    yakusuu_array_ab = []
    for i in range(1,ab+1):
        if ab % i == 0:
            yakusuu_array_ab.append(i)
    yakusuu_array.append(yakusuu_array_ab)

kouyakusuu = list(set(yakusuu_array[0]) & set(yakusuu_array[1]))
kouyakusuu.sort()

if len(kouyakusuu) == 0:
    print(1)
else:
    print(kouyakusuu[-k])

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())
g = gcd(a, b)
l = []
for i in range(1, g + 1):
    if g % i == 0:
        l.append(i)
l.reverse()
print(l[k - 1])

Submission status: Accepted

Solution code:
#import math

def gcd(m,n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!= 0:
            z = x%y
            x = y
            y =z
        else:
            return z


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

Max = int(gcd(A, B) )


list = [0] * 1000

j =0

if A == 1 or B == 1:
    print("1")
    quit()

for i in range(Max):

    if i == 0:
        continue
    if Max % i == 0:
        list[j] = i
        j += 1

if K == 1:
    print(Max)
    exit()

print(list[j - K+1])

Submission status: Accepted

Solution code:
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

if __name__ == "__main__":
    s = input()
    mylist = s.split()
    a = int(mylist[0])
    b = int(mylist[1])
    k = int(mylist[2])
    mygcd = gcd(a,b)
    cdList = []
    for i in range(1, mygcd+1, 1):
        if(a % i == 0 and b % i == 0):
            cdList.append(i)
    print(cdList[len(cdList) - k])

Submission status: Accepted

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

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

        return dl

ad = set(d(A))
bd = set(d(B))

div = sorted(set.intersection(ad, bd), reverse=True)

print(div[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

divs = [1]
div = 2
while div <= A and div <= B:
    if A % div == 0 and B % div == 0:
        divs.append(div)
    div += 1

print(divs[-K])

Submission status: Accepted

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

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

print(div[-k])

Submission status: Accepted

Solution code:
## print(type(range(19)))
hurui = list(range(101))
hurui2 =list(range(101))
## print(hurui)
counter = 2
while True:
    if counter > 100:
        break
    if hurui[counter] != 0:
        a = counter
        while True:
            if (a + counter) > 100:
                break
            a += counter
            hurui[a] = 0
            ## print(a)
    counter += 1
## print(list(set(hurui)))
sosu = list(set(hurui))

a, b, c = list(map(int, input().strip().split()))
ansa = []
ansb = []
for i in range(1, len(hurui2)):
    if (b % hurui2[i]) == 0:
        ansb.append(hurui2[i])
    if (a % hurui2[i]) == 0:
        ansa.append(hurui2[i])
    counter += 1
ans = list(set(ansa) & set(ansb))
# print(ansa)
# print(ansb)
# print(ans)
# print(sorted(ans))
print(sorted(ans, reverse=True)[c - 1])

Submission status: Accepted

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

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)
print(d[-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:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[-inp[2]])

Submission status: Accepted

Solution code:
data = input().split()
a = int(data[0])
b = int(data[1])
k = int(data[2])
 
ans = []
for i in range(1, a+1 if a < b else b+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

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

Submission status: Accepted

Solution code:
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
lis = num_lis[::-1]
print(lis[K - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int,raw_input().split())
a,b=min(a,b),max(a,b)
n=0
ans=1
for i in xrange(a,0,-1):
	if a%i==b%i==0:
		n=n+1
	if n==k:
		ans=i
		break
print ans

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:
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)+1):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Submission status: Accepted

Solution code:
"""
    正解数　A,B
    正の整数　Z：A,Bも割り切る
    出力：Zの内K番目に大きいもの
"""

a, b, k = map(int, input().split())
i = 1
z = []

while i <= 100:
    if (a % i == 0 and b % i == 0):
        z.append(i)
    i += 1
    
print(z[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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

Submission status: Accepted

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

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

tmp.reverse()
print(str(tmp[K-1]))

Submission status: Accepted

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


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

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

Submission status: Accepted

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

if A >= B:
    L, S = A, B
if A < B:
    L, S = B, A

while L%S != 0:
    tmp = L;
    L = S;
    S = tmp%S;

gcd = int(S)

if gcd == 1:
    print(1)
    exit()

com_div = []
com_div.append(gcd)
for i in range(1,gcd):
    if gcd % i == 0:
        com_div.append(i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c, d, e = map(int, input().split())
if c > d:
    max_num = c
    min_num = d
else:
    max_num = d
    min_num = c

li = []
for i in range(1, min_num+1):
    if max_num % i == 0 and min_num % i == 0:
        li.append(i)

list_num = abs(e - len(li))
print(li[list_num])

Submission status: Accepted

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

n = min(A, B)
count = 0
for i in range(n) :
    if A % (n - i) == 0 and B % (n - i) == 0 :
        count += 1
        if count == C :
            print(n - i)

Submission status: Accepted

Solution code:
x,y,z = map(int,input().split())
n = (y if x < y else x) 
n += 1
array = [1]
for i in range(1,n):
	if (x%i==0 and y%i==0):
		array.append(i)
array.reverse()
print(array[z-1])

Submission status: Accepted

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


from sys import stdin

############################################

import numpy as np
# read data for n sequences.
n = stdin.readline().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])

ans = []
for i in range(1, a+1):
    if a%i==0:
        ans.append(i)
ans=sorted(ans,reverse=True)
if a == 1:
    ans=[1]
count=0

for i in ans:
    if b%i==0:
        count+=1
    if count==c:
        break
print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

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