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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
N = []
n = min(A, B) + 1
for i in range(1, n):
  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())
ans = []

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

A, B, K = i_l()

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

print(arr[::-1][K-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

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)
x=x[::-1]
print(x[k-1])

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)
print(t[-k])

Submission status: Accepted

Solution code:
#x=int(input())
a,b,k=map(int,input().split())
#xl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ansl=[]

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

ansl.sort(reverse=True)

print(ansl[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

Submission status: Accepted

Solution code:
from fractions import gcd
import sys
a,b,k=map(int,input().split())
n=gcd(a,b)
#find the kth divisor of n
cnt=0
for i in range(n,0,-1):
    if n%i==0:
        cnt+=1
        if cnt==k:
            print(i)
            sys.exit()

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    ct=0
    c=min(a,b)
    for i in range(c,0,-1):
        if a%i==0 and b%i==0:
            ct+=1
            if ct==n:
                ans=i
    print(ans)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans[K*-1])

Submission status: Accepted

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

Submission status: Accepted

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

divs = []
N = max(A, B)
for i in range(1, N+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())

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

Submission status: Accepted

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

ma = max(a, b)
mi = min(a, b)
ans = []
if ma == mi:
    ans.append(ma)
    
for i in range(ma // 2, 0, -1):
    if ma % i == 0 and mi % i == 0:
        ans.append(i)
ans.append(1)
print(ans[k - 1])

Submission status: Accepted

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

    

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
t = min(a,b)
number =0
while k > number:
  if a%t==0 and b%t==0:
    number += 1
  t -= 1
print(t+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[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
ans = []
d = max(a, b)
for i in range(1, d+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())
l = []
for i in range(1,a+1):              # 100しかないから全部調べる
    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:
# 公約数列挙
# 重複する約数は1つにまとまるので注意
def make_common_divisors(x1, x2):
    cd = [1]
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cd.append(i)
    return cd

A,B,K = map(int,input().split())
print(make_common_divisors(A,B)[-K])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
from fractions import gcd
def make_divisor_list(num):
    if num<1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor=[]
        divisor.append(1)
        for i in range(2,num//2+1):
            if num%i==0:
                divisor.append(i)
        divisor.append(num)

        return divisor
l=make_divisor_list(gcd(a,b))
print(l[-k])

Submission status: Accepted

Solution code:
from fractions import gcd
A, B, K = map(int,input().split())
l = []
for k in range(1, gcd(A, B)+1):
  if all(i % k == 0 for i in [A, B]):
    l.append(k)
print(l[-K])

Submission status: Accepted

Solution code:
from fractions import gcd
A, B, K = map(int,input().split())
cnt = 0
for k in range(1, gcd(A, B)+1)[::-1]:
  if all(i % k == 0 for i in [A, B]):
    cnt += 1
  if cnt == K:
    print(k)
    exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,a+1):
  if a%i==0 and b%i==0:
    li.append(i)
    
li.sort(reverse=True)

print(li[k-1])

Submission status: Accepted

Solution code:
import fractions

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

base=fractions.gcd(A,B)
answers=[]

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

Submission status: Accepted

Solution code:
a=[]
A,B,K=map(int,input().split())
i=1
while i<=min([A, B]):
    if A%i==0 and B%i==0:
        a.append(i)
    i+=1
a.sort(reverse=True)

print(a[K-1])

Submission status: Accepted

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

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

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

cm = []
for v in am:
    if bm.count(v) != 0:
        cm.append(v)

print(cm[- k])

Submission status: Accepted

Solution code:
A,B,K = map(int, input().split())
num_list = []
w = min(A, B)
while w >= 1:
    if A % w == 0 and B % w == 0:
        num_list.append(int(w))
    w -= 1

print(num_list[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(divisor_list[-K])

Submission status: Accepted

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

print(l[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

da = make_divisors(A)
db = make_divisors(B)
common = da & db
common_list = list(common)
common_list.sort(reverse=True)
print(common_list[K-1])

Submission status: Accepted

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


def main():
    a, b, k = map(int, input().split())
    ab_cf = cf(a, b)
    ans = sorted(ab_cf)[-k]
    print(ans)


if __name__ == "__main__":
    main()

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

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)

    divisors.sort()
    return divisors


a_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = sorted([x for x in set(div_list) if div_list.count(x) > 1])

print(ans[-k])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

answer = []
ans = 1
max_ans = fractions.gcd(A, B)
while ans <= max_ans:
    if A % ans == 0 and B % ans == 0:
        answer.append(ans)
        ans += 1
    else:
        ans += 1
answer = sorted(answer, reverse=True)

print(answer[K-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
def main():
    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)
                exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

smaller_value = min(a, b)

divisors = []
for i in range(1, smaller_value // 2 + 1):
    if smaller_value % i == 0:
        divisors.append(i)
divisors.append(smaller_value)

larger_value = max(a, b)
count = 0
for d in reversed(divisors):
    if larger_value % d == 0:
        count += 1
        if count == k:
            print(d)
            break

Submission status: Accepted

Solution code:
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()

print(li[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,101):
  amariA = A % i
  amariB = B % i
  if amariA == 0 and amariB == 0:
    output.append(str(i))

print(output[-K])

Submission status: Accepted

Solution code:
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,s+1):
    if g%i==0:
        ans.add(i)
        ans.add(g//i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

Submission status: Accepted

Solution code:
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,min(a,b)+1):
    if a%i==0:
        if b%i==0:
            ans.add(i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

l = []

for i in range(1, 101):
    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())

count = 0

l = []

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

Submission status: Accepted

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

ans = [i for i in range(1, max(a, b) + 1) if a % i is 0 and b % i is 0]

ans.reverse()

print(ans[k - 1])

Submission status: Accepted

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

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC120

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)
        
print(sorted(l,reverse = True)[k-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

i = max(a, b)
idx = 0
while True:
    if a % i == 0 and b % i == 0:
        idx += 1

    if idx == k:
        break
    else:
        i -= 1

print(i)

Submission status: Accepted

Solution code:
def calc_divisiors(x):
    divisors=[]
    for i in range(1,x+1):
        if x % i == 0:
            divisors.append(i)
    return divisors

a,b,k = map(int,input().split())
a_divisiors = calc_divisiors(a)
b_divisiors = calc_divisiors(b)
# print(a_divisiors,b_divisiors)
l = list(set(a_divisiors)&set(b_divisiors))
l.sort(reverse=True)
# print(l)
print(l[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:
            print(i)
            break

Submission status: Accepted

Solution code:
import sys

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

cnt = 0

N = min(A,B) 

for i in range(N,0,-1):
  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())

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

Submission status: Accepted

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

l.sort(reverse=True)

print(l[k-1])

Submission status: Accepted

Solution code:
A, B, K = map(lambda x: int(x), input().split())
count = 0
for i in range(A if A < B else B, 0, -1):
    if A % i == B % i == 0:
        count += 1
    if count == K:
        print(i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from fractions import gcd

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

largest_divisor = gcd(A, B)
divisors = []
for d in range(1, largest_divisor):
    if A % d == 0 and B % d == 0:
        divisors.append(d)
divisors.append(largest_divisor)
print(divisors[-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:
a,b,k = map(int, input().split())
sp =[i for i in range(1, max(a,b)+1) if a%i == 0 and b%i==0]
sp.sort(reverse=True)
print(sp[k-1])

Submission status: Accepted

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


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

# 重複する約数を削除してから、リストに変換している
nums = list(set(temp_a) & set(temp_b))

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

print(nums[k-1])

Submission status: Accepted

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

print(div[cnt-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lst = []

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

lst.sort(reverse = True)

print(lst[K-1])

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)
print(L[-K])

Submission status: Accepted

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


split_num_list = []

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

Submission status: Accepted

Solution code:
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


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

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())
lis=[]

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

Submission status: Accepted

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