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

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

print(sorted(c)[-K])

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    return divisors

ls = make_divisors(a)
ls2 = make_divisors(b)
ls3 = (set(ls)&set(ls2))
ls3 = sorted(ls3,reverse=True)
print(ls3[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math

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

s = input().split(" ")
a = int(s[0])
b = int(s[1])
k = int(s[2])
c = gcd(a, b)
fac = []

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

print(fac[-k])

Submission status: Accepted

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

Submission status: Accepted

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


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

    cnt = 0
    for i in reversed(range(1, min(A, B)+1)):
        if A%i==0 and B%i==0:
            cnt += 1
        if cnt==K:
            print(i)
            return
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a, b, k = map(int, raw_input().split())
MAX_AB = max(a,b)

cnt = 0
ans = 0
for i in range(MAX_AB):
    j = MAX_AB - i

    if j == 0:
        continue

    if a%j == 0 and b%j == 0:
        cnt += 1
    if cnt == k:
        ans = j
        break

print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
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:
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
count = 0
result = []
for i in range(1, max(a,b)+1):
    if (a % i == 0) & (b % i ==0):
        count += 1
        result.append(i)
print(result[-k])

Submission status: Accepted

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

#a, bが100までの数なので、最大公約数の約数を探す
for i in range(1, 101):
    if a % i == 0 and b %i == 0:
        div.append(i)

div.sort(reverse = True)

print(div[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [i for i in range(100, 0, -1) if (A % i == 0) & (B % i == 0)]
print(l[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int(divisors[K-1]))

Submission status: Accepted

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

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

list.sort(cmn_dvs, reverse = True)
#print(cmn_dvs)
print(cmn_dvs[k-1])

Submission status: Accepted

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


def D(n):
    S=set()
    for i in range(1,n+1):

        if n / i ==  n // i:

            S.add(i)
    return S


A=D(A)
B=D(B)

A&=B
A=list(A)
A.sort(reverse=True)

print(A[K-1])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    a,b,k=map(int,input().split())
    from fractions import gcd
    g=gcd(a,b)
    A=divisors(g)
    print(A[-k])
resolve()

Submission status: Accepted

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

div_list = []

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

print(div_list[- k])

Submission status: Accepted

Solution code:
def main(A, B, K):
    i = min(A,B)+1
    counter = 0
    while(counter < K):
        i -= 1
        if(A%i == 0 and B%i == 0):
            counter += 1
        
    return i
        
    

args = input().split()

print(main(int(args[0]), int(args[1]), int(args[2])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    (a,b,k)=(int(i) for i in 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])

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cands = []
for i in range(1,int(math.sqrt(a*b)+1)):
    if a % i == 0 and b % i == 0:
        cands.append(i)

print(cands[::-1][k-1])

Submission status: Accepted

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

l = []

for i in range(X+1):
  j = i+1
  if A % j == 0 and B % j == 0:
    l.append(j)

# print(l)
print(l[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

cnt = 0

for i in reversed(range(1, 101)):
    if (A % i == 0) and (B % i == 0):
        cnt += 1
        if cnt == K:
            print(i)
            sys.exit()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
ans=[]
for i in range(1, 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())
temp=max(A, B)
num=[1]
for i in range(2, temp+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())
x=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        x.append(i)
    else:continue
print(x[-k])

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

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

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)
D = sorted(D,reverse=True)
print(D[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: break
print(i)

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

Submission status: Accepted

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

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

print(div[k-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
n = min(A, B)
while (cnt != K):
    if (A % n == 0 and B % n == 0): cnt += 1
    # print (n, cnt)
    n -= 1

print (n + 1)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
import fractions
start = fractions.gcd(A, B)
count = 0
for i in range(start, 0, -1):
  if A % i == 0 and B % i == 0:
    count += 1
    if count == K:
      print(i)
      exit()

Submission status: Accepted

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

al = [a/i for i in range(1,a+1) if a%i ==0]
bl = [b/i for i in range(1,b+1) if b%i ==0]

cd = sorted(list(set(al) & set(bl)))

print(int(cd[-k]))

Submission status: Accepted

Solution code:
input_lst = input().split()
a=int(input_lst[0])
b=int(input_lst[1])
k=int(input_lst[2])
count = 0
for i in range(a):
  if (a%(a-i)==0 and b%(a-i)==0):
    if count+1 == k:
      print(a-i)
      break
    else:
      count += 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(divisors[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    x = []
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            x.append(i)
    print(sorted(x)[-k])


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

print(result[k - 1])

Submission status: Accepted

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

Submission status: Accepted

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

List = []
c = 1
while c <= min(A,B):
    if A%c == 0 and B%c == 0:
        List.append(c)
    c += 1

print(List[K*(-1)])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

i = max(a,b)
count = 0
ans = 0
while True:
  if a%i == 0 and b%i==0:
    ans = i
    count += 1
  if count == k:
    break
  i -= 1
print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
A, B, K = map(int, input().split())
g = gcd(A, B)
k = 1
r = 0
res = 0
while True:
  if k > min(A, B):
    print(res)
    exit(0)
  if r == K:
    print(res)
    exit(0)
  if g % k == 0:
    res = g // k
    r += 1
  k += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def MAP(): return list(map(int,input().split()))

a,b,k = MAP()
ans = [i for i in range(1,min(a+1,b+1)) if (a%i==0) and (b%i==0)]
print(ans[-k])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
ans = []
if max(A,B) == 1:
	print(1)
	exit()
for i in range(1,max(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())
def calcgcd(a, b):
  if a > b:
    a, b = b, a
  while a > 0:
    a, b = b%a, a
  return b
d = calcgcd(A, B)
L = []
for i in range(1, d+1):
  if d%i == 0:
    L.append(i)
r = L[-K]
print(r)

Submission status: Accepted

Solution code:
from fractions import gcd
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)
      break

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)

    #divisors.sort(reverse=True)
    return divisors

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

a_list=make_divisors(a)
b_list=make_divisors(b)
#print(a_list,b_list)
a_and_b=set(a_list) & set(b_list)
#print(a_and_b)
ans=sorted(list(a_and_b),reverse=True)
print(ans[k-1])

Submission status: Accepted

Solution code:
import fractions
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
a = make_divisors(fractions.gcd(A,B))

ans = a[-K]
print(ans)

Submission status: Accepted

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

div = []

for i in range(1, min(A, B)+1):
    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())
s=[]
for i in range(min(a,b)):
  if a%(i+1)==0 and b%(i+1)==0:
    s.insert(0,i+1)

print(s[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

result=result[::-1]
#print(result)
print(result[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 == b % i == 0:
        lst.append(i)
print(lst[::-1][k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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


lres = []

for i in range(0, len(ya)):
    if ya[i] in yb:
        lres.append(ya[i])

lres.reverse()

print(lres[k - 1])

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
small = min(A, B)
both = [i for i in range(1, small+1)]
gcd = []

for i in both:
    if A % i == 0 and B % i == 0:
        gcd.append(i)

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

Submission status: Accepted

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

l1=[]
l2=[]
for i in range(1,a+1):
    if a%i ==0:
        l1.append(i)

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

l1 = set(l1)
l2 = set(l2)

l = sorted(l1 & l2, reverse=True)
print(l[k-1])

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 and B%i == 0:
        CD.append(i)
print(CD[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

div = []

for i in range(1, 101):
    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())
def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
A = cf(a, b)
A.sort(reverse = True)
print(A[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)
print(l[-K])

Submission status: Accepted

Solution code:
"""#################################################################
【ABC120】
B_K-th_Common_Divisor
#################################################################"""

#インポート
import sys

#入力用
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(input())
def S(): return input()

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

Submission status: Accepted

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

Submission status: Accepted

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

div_a = set()
div_b = set()

for i in range(1, 101):
    if a % i == 0:
        div_a.add(i)
    if b % i == 0:
        div_b.add(i)

ans = sorted(list(div_a & div_b))
print(ans[-k])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a+1):
    if a%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())
 
count=0
 
for i in range(1,min(a,b)+1)[::-1]:
  if a%i==0 and b%i==0:
    count +=1
  if count==k:
    num=i
    break
  
print(num)

Submission status: Accepted

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

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

print(d[-K])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
count = 0
div = max(a,b)
while True:
    if a % div == 0 and b % div == 0:
        count += 1
        if count == k:
            print(div)
            exit()
    div -= 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b,k = list(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)
if(len(res) == 0):
  print(res[0])
else:
  print(res[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if A <= B:
    A=A
    B=B

else :
    C=A
    A=B
    B=C

#A<B

li=[]

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

A%1
#print(li)        
        
if len(li)==1: 
    print(li[0])
else:
    print(li[-K])

Submission status: Accepted

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

Submission status: Accepted

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

#no 1 is a(len-1)
# no k is a(lent-K)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
A,B,K = map(int, input().split())
tmp = 1
ans = []
while tmp <= min(A,B):
    if A%tmp==0 and B%tmp==0:
        ans.append(tmp)
    tmp += 1

print(ans[-K])

Submission status: Accepted

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

A,B,K=map(int, input().split())
count=0
for i in reversed(range(1,101)):
    if A%i==0 and B%i == 0:
        count+=1
    if count == K:
        break
print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

def main():
    A,B,K = map(int, input().split())
    a = make_divisors(A)
    b = make_divisors(B)
    a = set(a) & set(b)
    a = sorted(list(a), reverse=True)
    print(a[K-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

lis=[]
if a>b:
    for i in range(b):
        if a%int(b-i)==0 and b%int(b-i)==0:
            lis.append(int(b-i))

else:
    for i in range(a):
        if a%(a-i)==0 and b%(a-i)==0:
            lis.append(int(a-i))

#print(lis)
print(lis[c-1])

Submission status: Accepted

Solution code:
def main():
    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
            # print(i)
            if count == k:
                print(i)
                break

if __name__ == "__main__":
    main()

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:
from fractions import gcd

a, b, k = list(map(int, input().split()))
count = 1
for i in range(gcd(a, b), 0, -1):
    if a % i != 0 or b % i != 0:
        continue
    else:
        if count == k:
            print(i)
            break
        else:
            count += 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[-k])

Submission status: Accepted

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

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


main()

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
num = []
for i in range(1,min(A,B)+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())
M = 0
l = []
if A>B:
  M = A
else:
  M = B
for _M in range(1,M+1):
  if A%_M==0 and B%_M==0:
    l.append(_M)
print(l[-K])

Submission status: Accepted

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


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


cf_list = cf(A, B)
print(cf_list[-C])

Submission status: Accepted

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