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

ans=[]
i=min(a,b)
while(len(ans)<k):
    if (a% i==0) and (b%i==0):
        ans.append(i)
    i-=1
print(ans[-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())
kouyakusuu = []

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

print(kouyakusuu[-1 * 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())
c = 0
ans = []
for i in reversed(range(min(A, B))):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        ans = i + 1
        c += 1
        if c == K:
            print(ans)
            exit()
        else:
            pass

Submission status: Accepted

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

Submission status: Accepted

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

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)

print(arr[-k])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(sorted(lst)[len(lst)-k])

Submission status: Accepted

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

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

for j in range(k-1):
  lst.remove(max(lst))
  
print(max(lst))

Submission status: Accepted

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

Submission status: Accepted

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

nums=[]

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

#print(nums)
print(nums[-k])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(li[-K])

Submission status: Accepted

Solution code:
def main():
    a,b,k=map(int,input().split())
    print(make_divisors(gcd(a,b))[k-1])
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[::-1]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
main()

Submission status: Accepted

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

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

print(tmp[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

    for j in range(k-1):
        c.remove(max(c))

    print(max(c))


if __name__ == "__main__":
    test()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
da = {int(i) for i in range(1,a+1) if a%i == 0}
# print('aの正の約数です',da)
db = {int(i) for i in range(1,b+1) if b%i == 0}
# print('bの正の約数です',da)
dab = da & db
# print('aとbの正の公約数です',dab)
dabl = list(dab) 
# print('リスト化しました',dabl)
dabl.sort()
# print('ソートしました',dabl)
print(dabl[-k])

Submission status: Accepted

Solution code:
A,B,C= [int(i) for i in input().split()]
while(True):
	D = A%B
	if D == 0:
		if C == 1:
			print(B)
			exit()
		break
	A=B
	B=D
D = 1 + B//2
c =0
for i in range(B):
	if B%D == 0:
		c += 1
	if c == C-1:
		print(D)
		break
	D -= 1

Submission status: Accepted

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

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
        if count == K:
            return i

if __name__ == '__main__':
    print(main())

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
print(cf(a,b)[-k])

Submission status: Accepted

Solution code:
#B - K-th Common Divisor(ABC120)
A,B,K=map(int, input().split())
C=[]
i=1
while i!=min(A,B)+1:
    if A%i==0 and B%i==0:
        C.append(i)
    i+=1
print(sorted(C)[-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:
import fractions
a,b,k=map(int,input().split())

gcd=fractions.gcd(a,b)
div=[]
for i in range(1, int(gcd**0.5)+1):
  if gcd%i==0:
    div.append(i)
    if i!= gcd//i:
      div.append(gcd//i)
print(sorted(div,reverse=True)[k-1])

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
A,B,K = map(int,input().split())
nums1=make_divisors(A)
nums2=make_divisors(B)
ans=0
count=0
for a in nums1:
    if a in nums2:
        count+=1
    if count==K:
        ans=a
        break
print(ans)

Submission status: Accepted

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

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

print(tmp[-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:
a, b, k = (int(i) for i in input().split())

div_a = {d for d in range(1,a+1) if a%d == 0}
div_b = {d for d in range(1,b+1) if b%d == 0}
com_d = sorted(list(div_a & div_b),reverse=True)
print(com_d[k-1])

Submission status: Accepted

Solution code:
a,b,k =map(int, input().split())
c = min(a, 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:
a,b,k = map(int,input().rstrip().split())
c = []

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

print(str(c[-k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

    # divisors.sort()
    return divisors

A, B, K = map(int,input().split())
a = set(make_divisors(A))
b = set(make_divisors(B))
c = sorted(list(a & b))
print(c[-1 * K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

count = 0
k = GCD
ans = 0
while count < K:
    if GCD % k == 0:
        count+=1
        ans = k
    k -= 1

print(ans)

Submission status: Accepted

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
        
a,b,k = map(int,input().split())
cnt=1

ans=gcd(a,b)
n=ans
if not(k==1):
    for i in range(n):
        c=n-i-1
        if(a%c==0 and b%c==0):
            ans=n-i-1
            cnt+=1
        if(cnt==k):
            break
      
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

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

Submission status: Accepted

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

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)

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
ad = [i for i in range(1, a + 1) if a % i == 0]
bd = [i for i in range(1, b + 1) if b % i == 0]
print(sorted(set(ad) & set(bd))[-k])

Submission status: Accepted

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

list=[]

if a>b:
    tmp=a
else:
    tmp=b

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

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:
import sys
a,b,k=map(int,input().split())
count=0
for i in reversed(range(1,min(a,b)+1)):
  if a%i==0 and b%i==0:
    count+=1
    if count==k:
      print(i)
      sys.exit()

Submission status: Accepted

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

cd = []
for d in range(1, max(a, b) + 1):
  if a % d == 0 and b % d == 0:
    cd.append(d)

print(cd[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

a,b,k=map(int,input().split())
d=fractions.gcd(a,b)
l=[]
for i in range(1,d+1):
        if a%i==0 and b%i==0:
                l.append(i)

l=l[::-1]
print(l[k-1])

Submission status: Accepted

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


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

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

# inputb = input().split()
# inputbint = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

min = min([a, b])
cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(0, 1000)[::-1]:
    if A % j == 0 and B % j == 0:
        K -= 1
        if K == 0:
            print(j)
            break

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
cnt = 0
for i in range(A, 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())
cnt = 0
for i in range(A, 0, -1):
  if A % i == 0 and B % i == 0:
    cnt += 1
  if cnt == K:
    print(i)
    break

Submission status: Accepted

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


def solve(A, B, K):
    mx = min(A, B)
    div_ab = list(filter(
        lambda x: A % x == 0 and B % x == 0,
        range(1, mx+1)))
    return div_ab[-K]


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

    ans = solve(A, B, K)

    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

c = 0

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

Submission status: Accepted

Solution code:
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

a_l.sort(reverse=True)
b_l.sort(reverse=True)

cnt = 0
for i in a_l:
    for j in b_l:
        if i == j:
            cnt += 1
            if cnt == k:
                print(i)
                exit()

Submission status: Accepted

Solution code:
import fractions

ABK = list(map(int,input().split()))
LCM = ABK[0] * ABK[1] // fractions.gcd(ABK[0],ABK[1])
count = 0

while count < ABK[2]:
    if ABK[0] % LCM == 0:
        if ABK[1] % LCM == 0:
            count = count + 1
    if count != ABK[2]:
        LCM = LCM - 1

print(LCM)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, N+1):
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)

print(list_gcd[-K])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table

# file read
a, b, c = map(int, input().split())

elm = sorted(list(divisor(a) & divisor(b)), reverse = True)
print(elm[c-1])

Submission status: Accepted

Solution code:

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

print(ptn[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions

a, b, k = map(int, input().split())
gcd = fractions.gcd(a, b)
divisor = []
for i in range(int(gcd ** 0.5)):
    if gcd % (i + 1) == 0:
        divisor.append(i + 1)
        if gcd // (i + 1) != i + 1:
            divisor.append(gcd // (i + 1))
divisor.sort(reverse = True)
print(divisor[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[len(li)-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K = list(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)

l.sort(reverse=True)

print(l[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[len(li)-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()

Submission status: Accepted

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

Submission status: Accepted

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

ans = []

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

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

Submission status: Accepted

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

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
a = make_divisors(A)
b = make_divisors(B)
c = sorted(set(a)&set(b))
print(list(c)[-K])

Submission status: Accepted

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

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

Submission status: Accepted

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

i = min(A, B)
while K != 0:
    if A % i == 0 and B % i == 0:
        K -= 1
    i -= 1

i += 1
print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
s = a

while True:
    if a%s == 0 and b%s == 0:
        cnt += 1
        if cnt == k:
            print(s)
            exit()
    s -= 1

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
ali = set(make_divisors(a))
bli = set(make_divisors(b))
li = sorted(list(ali & bli))
print(li[-k])

Submission status: Accepted

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

Submission status: Accepted

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

num_list = []

if a > b:
    for i in range(b, 0, -1):
        if a % i == 0 and b % i == 0:
            num_list.append(i)

else:
    for i in range(a, 0, -1):
        if a % i == 0 and b % i == 0:
            num_list.append(i)

print(num_list[c-1])

Submission status: Accepted

Solution code:
import sys

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)
if l == []:
    print(1)
    sys.exit()
l.sort(reverse=True)
print(l[k-1])

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)

sorted_list = sorted(list,reverse=True)
print(sorted_list[k-1])

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

Submission status: Accepted

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

def koyaku(x):
    i = 1
    koyaku_list = []
    while i * i <= x:
        if x % i == 0:
            koyaku_list.append(i)
            koyaku_list.append(x // i)
        i += 1
    return list(set(koyaku_list))

a_koyaku = koyaku(a)
b_koyaku = koyaku(b)

common_koyaku = set(a_koyaku).intersection(set(b_koyaku))
ans = sorted(common_koyaku, reverse=True)[k-1]

print(ans)

Submission status: Accepted

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

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

print(diflist[-K])

Submission status: Accepted

Solution code:
S = input()

S = S.split()

S = list(map(int, S))

A = S[0]
B = S[1]
K = S[2]

list = []

if A >= B:
  C = B
else:
  C = A

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

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

Submission status: Accepted

Solution code:
import math
import sys
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)
    sys.exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC  120, B - kth common divisor
a, b, k = map(int, input().split(' '))

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

print(d[-k])

Submission status: Accepted

Solution code:
from fractions import*
a,b,k=map(int,input().split());c=0
for i in range(a,0,-1):
  if not gcd(a,b)%i:
    c+=1
    if c==k:print(i)

Submission status: Accepted

Solution code:
from fractions import*
a,b,k=map(int,input().split());s=[]
for i in range(1,a+1):
  if not gcd(a,b)%i:
    s+=[i]
s.sort(reverse=True)
print(s[k-1])

Submission status: Accepted

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

def listing(numb):
    temp = []
    for i in range(1, numb+1):
        if numb % i == 0:
            temp.append(i)
    return temp

alist = listing(a)
blist = listing(b)

alist.sort(reverse=True)
blist.sort(reverse=True)
counter = 0

for i in alist:
    if i in blist:
        counter += 1
        if counter == k:
            print(i)
            break

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A,B,K= map(int, sys.stdin.readline().split())
    l = []
    for i in range(1,min(A,B)+1):
        if A % i ==0 and B%i ==0:
            l.append(i)
    l.reverse()
    print(l[K-1])

Submission status: Accepted

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

if(a >= b):
  div = b
else:
  div = a

cnt = 0

for i in range(div):
  res_a = a % (div - i)
  res_b = b % (div - i)

  if ((res_a == 0) & (res_b == 0)):
    cnt += 1
    if(cnt == k):
      print (div - i)
      break

Submission status: Accepted

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

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

print(ans[-K])

Submission status: Accepted

Solution code:
x,y,n=map(int,input().split())

cnt=0
for i in range(100,0,-1):
	if x%i==0 and y%i==0:
		cnt+=1
		if cnt==n:
			print(i)
			break

Submission status: Accepted

Solution code:
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)),reverse=True)
print(and_list[k-1])

Submission status: Accepted

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

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