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 = list(map(int, input().split()))
ans = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        ans.append(i)
print(ans[-1 * K])

Submission status: Accepted

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

n = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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


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

    divisors.sort(reverse=True)
    return divisors


print(make_divisors(gcd(a, b))[k-1])

Submission status: Accepted

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

s = []

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

sorted(s)

s = s[::-1]

print(s[k-1])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
sa = [i for i in range(1, 101) if a % i == 0]
sb = [i for i in range(1, 101) if b % i == 0]
li = set(sa) & set(sb)
print(sorted(li, reverse=True)[k - 1])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
divs = []
for i in range(1,101):
  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())
def divide(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

aa = set(divide(a))
bb = set(divide(b))
c = aa & bb
cc = list(c)
cc.sort(reverse = True)
print (cc[k-1])

Submission status: Accepted

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

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

print(new[-K])

Submission status: Accepted

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

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

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

AAA =make_divisors(A)
BBB =make_divisors(B)

CCC = []

for i in range(len(AAA)):
    if AAA[i] in BBB:
        CCC.append(AAA[i])

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

Submission status: Accepted

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

a,b,k = map(int, input().split())
a_ = set(divisionize(a))
b_ = set(divisionize(b))
c = sorted(list((a_&b_)))[::-1]
print(c[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
def gcd(a, b):
  if a < b:
    return gcd(b, a)
  elif b == 0:
    return a
  else:
    return gcd(a%b, b)
C = gcd(A, B)

def Cs(C):
  i = 1
  tail = []
  while i*i < C:
    if C%i == 0:
      yield i
      tail.append(C//i)
    i += 1

  if i*i == C:
    yield i
  yield from tail[::-1]

xs = list(Cs(C))
print(xs[-(K)])

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,s = map(int,input().split())

l = [0]*100
k = 0

for i in range(1,101):
	if a%i==0 and b%i==0 :
		l[k] = i
		k = k+1

l.sort()

print(l[99-s+1])

Submission status: Accepted

Solution code:
# ABC 120: B – K-th Common Divisor
a, b, k = [int(s) for s in input().split()]

divisors = []

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

divisors.sort(reverse=True)

print(divisors[k - 1])

Submission status: Accepted

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

Al = []
Bl = []

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

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

ABl = []
for i in range(len(Al)):
    for j in range(len(Bl)):
        if Al[i] == Bl[j]:
            ABl.append(Al[i])

ABl.sort(key=lambda x: -x)

print(ABl[K - 1])

Submission status: Accepted

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

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

print(n[-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())

cnt = 0
ans = 0
for i in reversed(range(1, 101)):
    if a%i == b%i == 0:
        cnt+=1
        if cnt == k:
            ans = i
            break
            
print(ans)

Submission status: Accepted

Solution code:
import math
#import fractions as math
a,b,c = map(int,input().split())
list1 = []
def insu(a,b):
    global list1
    for i in range(1,min(a,b)+1):
        if a%i==0 and b%i==0:
            list1.append(i)

if __name__ == "__main__":
    insu(a,b)
    print(list1[-c])

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)
if min(A, B) == 1:
  print(1)
else:
  print(l[-K])

Submission status: Accepted

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

A,B,K = map(int, input().split())
g = GCD(A,B)
i = 1
glist = []
while i*i<=g:
    if g % i == 0:
        glist.append( i )
        if i*i!=g:
            glist.append( g//i )
    i+=1;
glist.sort(reverse=True)
print(glist[K-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

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 == 0 and B % i == 0:
		lst.append(i)
lst1 = sorted(lst, reverse = True)
print(lst1[K - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019-11-12 21:58:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

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

def main():
    a, b, k = [int(x) for x in sys.stdin.readline().split()]

    n = gcd(a, b)
    count = 0
    while True:
        if a % n == 0 and b % n == 0:
            count += 1
            if count == k:
                print(n)
                sys.exit()
        n -= 1


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import fractions
a,b,K = map(int,input().split())
g = fractions.gcd(a,b)
cnt = 0
ans = 0
for i in range(g,0,-1):
    if g % i == 0:
        cnt += 1
        if cnt == K:
            ans = i
            break
    else:
        pass
print(ans)

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
    
al = make_divisors(a)
bl = make_divisors(b)

abl = sorted(list(set(al) & set(bl)), reverse=True)
print(abl[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[-K])

Submission status: Accepted

Solution code:
a,b,c=map(int, input().split())
al=[]
bl=[]
for i in range(1,a+1):
    if a%i==0:
        al.append(i)
for i in range(1,b+1):
    if b%i==0:
        bl.append(i)
co=sorted(list(set(al)&set(bl)))
print(co[-c])

Submission status: Accepted

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

print(d[-k])

Submission status: Accepted

Solution code:
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())
    divisor1 = set(make_divisors(a))
    divisor2 = set(make_divisors(b))
    divisor3 = divisor1 & divisor2
    divisor3 = sorted(list(divisor3))

    print(divisor3[-k])


if __name__ == '__main__':
    main()

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


def main():
    a,b,k = map(int,input().split())
    divisor1 = set(divisor(a))
    divisor2 = set(divisor(b))
    divisor3 = divisor1 & divisor2
    divisor3 = sorted(list(divisor3))

    print(divisor3[-k])


if __name__ == '__main__':
    main()

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)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(l[-K])

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in 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())
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:
# -*- coding: utf-8 -*-
A, B, K = map(int, input().split())
l = [1]

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(a):
  if a % (i+1) == 0:
    al.append(i+1)
for i in range(b):
  if b % (i+1) == 0:
    bl.append(i+1)

com = sorted(list(set(al) & set(bl)), reverse=True)
print(com[k-1])

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

main()

Submission status: Accepted

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

divider_A = set()
divider_B = set()

for i in range(1, A+1):
  if A % i == 0:
    divider_A.add(i)

for i in range(1, B+1):
  if B % i == 0:
    divider_B.add(i)

print(sorted(divider_A & divider_B, reverse=True)[K-1])

Submission status: Accepted

Solution code:
import sys
import fractions


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    ans = [1]
    for i in range(2, gcd + 1):
        if gcd % i == 0:
            ans.append(i)
    print(ans[-k])


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

ls.sort()
print(-ls[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)
print(ans[len(ans)-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = [int(_) for _ in 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_list = list()
for i in range(1,min(A,B)+1):
	if A%(i) == 0 and B%(i) == 0:
		ans_list.append(i)
print(ans_list[-1*K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import fractions

a,b,k = [int(x) for x in stdin.readline().rstrip().split()]

li = [a,b]
def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

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
            
l = gcd_all(li)

lin = make_divisors(l)

print(lin[-1*k])

Submission status: Accepted

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

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

ans = div[-k]
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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


for n in range(0,100):
    if a%(100-n) == b%(100-n) == 0:
        m += 1
        o = 100-n
    if m == k:
        break


print(o)

Submission status: Accepted

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

a, b, c = 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[::-1][c-1])

Submission status: Accepted

Solution code:
import fractions
a,b,k=map(int,input().split())
gcd=fractions.gcd(a,b)
c=0
for i in range(1,gcd+1):
	if gcd%i==0:
		ans=gcd//i
		c+=1
	if c==k:
		break
print(ans)

Submission status: Accepted

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

c = 0
for i in range(max(a,b), 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())
l = [x for x in range(1, 101) if A % x == 0 and B % x == 0]
print(l[-K])

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

minimum = min(A, B)
maximum = max(A, B)

divers = []
# 小さいほうの約数を求める
for i in range(1, minimum+1):
    if minimum % i == 0:
        divers.append(i)

common_divers = []
# 公約数を求める
for i in divers:
    if maximum % i == 0:
        common_divers.append(i)
#print(common_divers)

# K番目を出力する
print(common_divers[-K])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(A,0,-1):
    if A%i == 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 n in range(1,max(A,B)+1):
    if A % n == 0 and B % n == 0:
        L.append(n)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
n = gcd(a, b)
div_list = []
for i in range(1, n+1):
    if n%i == 0:
        div_list.append(i)
print(div_list[-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:
def main():
    A, B, K = map(int, input().split())
    count = 0
    number = min(A, B)
    while True:
        if A % number == 0 and B % number == 0:
            count += 1
            if count == K:
                break
        number -= 1
    print(number)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

# ユークリッドの互除法
# a が最大公約数になっている
while b:
    a, b = b, a % b

a_divisors = []

for i in range(1, int(a ** 0.5) + 1) :
    if a % i == 0 :
        a_divisors.append(i)
        if a // i != i :
            a_divisors.append(a // i)

a_divisors.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

    num = 101
    index = 0
    while(index != K):
        num -= 1
        if A%num==0 and B%num==0:
            index += 1
    print(num)

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:
# ABC120B - K-th Common Divisor
def main():
    *AB, K = map(int, input().split())
    A, B = sorted(AB)
    div = [i for i in range(1, A + 1) if A % i == 0 and B % i == 0]
    div.sort(reverse=1)
    ans = div[K - 1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

cnt=0

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for i in range(1, 101):
    if a % i == b % i == 0:
        ans.append(i)

print(ans[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def cf(n1,n2):
    cf=[1]
    for i in range(2,min(n1,n2)+1):
        if n1%i==0 and n2%i==0:
            cf.append(i)
    return cf
a, b, k = map(int, input().split())
nums = cf(a,b)
print(nums[-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)*(b%i==0):l.append(i)
print(l[-k])

Submission status: Accepted

Solution code:
x = [int(i) for i in input().split()]
cnt = 0
ans = []
for i in range(1,min(x[0],x[1])+1):
    if(x[0] % i == 0 and x[1] % i == 0):
        ans.append(i)

print(ans[-x[2]])

Submission status: Accepted

Solution code:
import sys
A,B,K = map(int,input().split())
a = []
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 
g = gcd(A,B)
s = 1 
for i in range (g,0,-1):
  if g % i == 0:
    s = s + 1
    if s-1 == K:
      print(i)
      sys.exit()

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return sorted(divisors, reverse=True)
def gcd(a, b):
    if b==0:
        return a
    while b>0:
        a, b = b, a%b
    return a

A, B, K = map(int, input().split())
divs = make_divisors(gcd(A, B))
print(divs[K-1])

Submission status: Accepted

Solution code:
from sys import stdin

A,B,K = map(int,stdin.readline().strip().split())

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

print(ans)

Submission status: Accepted

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

lst = []
for i in range(1,max(A,B) + 1):
    if (A / i).is_integer() and (B / i).is_integer():
       lst.append(i)
lst.sort(reverse=True)
print(lst[K - 1])

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
tmp = 101
num = 0
while num!=K:
    tmp -= 1
    if A%tmp == 0 and B%tmp == 0:
        num += 1
print(tmp)

Submission status: Accepted

Solution code:
# coding: utf-8
A,B,K = map(int, input().split())

a = list(range(1,min(A+1,B+1)))
a = sorted(a, reverse=True)
cnt = 0

#print(a)
for i in a:
  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())

divisor_list = [x for x in range(1, max(A,B)+1) if A%x == 0 and B%x == 0]
print(divisor_list[-K])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
a_list=list(range(1,a+1))
b_list=list(range(1,b+1))
a1=[]
b1=[]
for i in a_list:
    if a%i==0:
        a1.append(i)
for i in b_list:
    if b%i==0:
        b1.append(i)
a_b=set(a1)&set(b1)
a_blist=list(a_b)
a_blist.sort()
print(a_blist[-k])

Submission status: Accepted

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

N=min(A,B)
cnt=0
for i in range(N,-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())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions as fr

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())
c = fr.gcd(a, b)
d = make_divisors(c)
print(d[-k])

Submission status: Accepted

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

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

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=map(int, input().split())

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

def yakusuu(n):
    y=[]
    for i in range(1,-(-n//2)+1):
        if n%i==0:
            y.append(i)
            y.append(n//i)
        y=list(set(y))
        y.sort()
    return(y)
        
print(yakusuu(gcd(A,B))[-K])

Submission status: Accepted

Solution code:
def divisor(n): #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())

aa=divisor(A)
bb=divisor(B)

c=sorted(list(set(aa) & set(bb)))
#print(c)

print(c[-K])

Submission status: Accepted

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

def divider(a):
    res = set()
    for i in range(1,int(a**0.5)+1):
        if a%i == 0:
            res.add(i)
            res.add(a//i)
    res = list(res)
    res.sort()
    return res


def main():
    """ main """
    A,B,K = map(int, input().split())
    arr = divider(gcd(A,B))
    print(arr[-K])

if __name__ == '__main__':
    main()