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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = list(map(lambda x: int(x), input().split(" ")))
cd = []
for i in range(min([A,B])):
  if A % (i + 1) == 0 and B % (i + 1) == 0:
    cd.append(i+1)
 
print(cd[-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)
      exit()

Submission status: Accepted

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

def make_div(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

print(sorted(set(make_div(A))&set(make_div(B)), reverse=True)[K-1])

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b, k = LI()
    v = []
    for i in range(1, 101):
        if a % i == 0 and b % i == 0:
            v.append(i)
    v = v[::-1]
    print(v[k-1])


main()

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)
ans.sort(reverse=True)
print(ans[K-1])

Submission status: Accepted

Solution code:
import sys
from math import gcd


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    a, b, k = nm()
    arr = make_divisors(gcd(a, b))
    print(arr[-k])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

L = sorted(l)
print(L[-k])

Submission status: Accepted

Solution code:
def resolve():
    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])
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

print(i)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for i in range(1, 100):
    if A % i == 0:
        sho = A / i
        if B % sho == 0:
            count += 1
    if count == K:
        print(int(sho))
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! python3
#  solve_120_B.py

import math

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

gcd_of_AB = math.gcd(A,B)
l = []

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

lim = min(A,B)

count = 0
for i in range(lim,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())
count=0
i=min(A,B)+1
while count<K:
    i-=1
    if A%i==0 and B%i==0:
        count+=1
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = input().strip().split()
A, B, C = [int(A), int(B), int(C)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
i=0
j=min(A,B)+1
while i<K:
  j-=1
  if A%j==0 and B%j==0:
    i+=1
print(j)

Submission status: Accepted

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

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

count = 0
for i in range(A,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 = input().split(" ")
A, B, K = int(A), int(B), int(K)

res = []

for i in range(A, 0, -1):
  if A % i == 0 and B % i == 0:
    res.append(i)

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

Submission status: Accepted

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

print(count[-k])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    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
main()

Submission status: Accepted

Solution code:
# abc120_b.py
# https://atcoder.jp/contests/abc120/tasks/abc120_b

# ★ WA:10
# sample_02
# testcase_1
# testcase_10
# testcase_2
# testcase_3
# testcase_5
# testcase_6
# testcase_7
# testcase_8
# testcase_9

# B - K-th Common Divisor /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 正整数 A,Bが与えられます。
# Aも B も割り切る正整数のうち、K番目に大きいものを求めてください。
# なお、与えられる入力では、Aも B も割り切る正整数のうち K番目に大きいものが存在することが保証されます。

# 制約
#     入力は全て整数である。
#     1≤A,B≤100
#     Aも B も割り切る正整数のうち、K番目に大きいものが存在する。
#     K≥1

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B K

# 出力
# Aも B も割り切る正整数のうち、K番目に大きいものを出力せよ。

# 入力例 1
# 8 12 2

# 出力例 1
# 2

# 8と 12 を割り切る正整数は 1,2,4 です。 この中で 2 番目に大きいものは 2です。

# 入力例 2
# 100 50 4

# 出力例 2
# 5

# 入力例 3
# 1 1 1

# 出力例 3
# 1


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # line = lines[0]
    # N = int(lines[0])
    A, B, K = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    cnt = 0

    for i in range(1, 101):
        if A % (101-i) == 0 and B % (101-i) == 0:
            cnt += 1
        if cnt == K:
            return [(101-i)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['8 12 2']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['100 50 4']
        lines_export = [5]
    if pattern == 3:
        lines_input = ['1 1 1']
        lines_export = [1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in 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:
import numpy as np
a,b,k = map(int,input().split())
c = np.gcd(a,b)
print([i for i in range(1,c+1) if c%i==0][-k])

Submission status: Accepted

Solution code:
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():

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

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit()



if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

a,b,k=map(int,input().split())
print(sorted(list(set(divisors(a))&set(divisors(b))))[::-1][k-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)
b = sorted(a, reverse=True)
print(b[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())
lst=[]
a=min(A,B)
for i in range(1,a+1):
    if A%i==0:
        if B%i==0:
            lst.append(i)
lst.reverse()
print(lst[K-1])

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
i = 1
d = []
while True:
  if a % i ==0 and b % i ==0:
    d.append(i)
  if i > max(a,b):
    break
  else:
    i += 1
print(d[-c])

Submission status: Accepted

Solution code:
#公約数を求める
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

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
A,B,K = map(int, input().split())

#公約数
div =cf(A,B)


print(div[-K])

Submission status: Accepted

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

count = 0
import math
R = []
for i in range(1,int(math.sqrt(A))+1+1):
    if A%i == 0:
        R.append(i)
        if not i == A//i:
            R.append(A//i)
R.sort(reverse=True)
for r in R:
    if B%r==0:
        count+=1
        if count == K:
            print(r)

Submission status: Accepted

Solution code:
def com_div(x, y):
    dv = []
    for i in range(min(x, y), 0, -1):
        if x % i == 0 and y % i == 0:
            dv.append(i)
    return dv


a, b, k = list(map(int, input().split()))
print(com_div(a, b)[k - 1])

Submission status: Accepted

Solution code:
def com_div(x, y):
    dv = []
    m = min(x, y)
    for i in range(1, m + 1):
        if x % i == 0 and y % i == 0:
            dv.append(i)
    dv.sort()
    return dv[::-1]


a, b, k = list(map(int, input().split()))
print(com_div(a, b)[k - 1])

Submission status: Accepted

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

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

Submission status: Accepted

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

def divisor_list(n):
    i = 1
    array = []
    while i * i <= n:
        if n % i == 0:
            array.append(i)
            array.append(n//i)
        i += 1
    array = list(set(array))
    return array


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

print(sorted(result_list)[-K])

Submission status: Accepted

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

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

divisors = divisors[::-1]
print(divisors[K - 1])

Submission status: Accepted

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

n = 0
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):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k])

if __name__ == '__main__':
    main()

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)

print(lst[-K])

Submission status: Accepted

Solution code:
def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break
main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
"""
全探索
1からmin(a,b)の中でaとbを割り切るものの数をカウントする
"""
a, b, k = map(int, input().split())
counter = 0
for i in list(range(1,min(a,b)+1))[::-1] :
    if a%i == 0 and b%i == 0 :
        counter += 1
    if counter == k :
        print(i)
        break

Submission status: Accepted

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

def divisor_list(n):
    i = 1
    array = []
    while i * i <= n:
        if n % i == 0:
            array.append(i)
            array.append(n//i)
        i += 1
    array = list(set(array))
    return array

for i in divisor_list(A):
    for j in divisor_list(B):
        if i == j:
            result_list.append(i)

print(sorted(result_list)[-K])

Submission status: Accepted

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

    divisors.sort()
    return divisors
    
lstA = make_divisors(A)
lstB = make_divisors(B)
#print(lstA,lstB)
fin = []

for i in lstA:
    if i in lstB:
        fin.append(i)
#print(fin)
fin.sort(reverse = True)
print(fin[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

if __name__ == '__main__':

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

	mini = min(a,b)
	d = deque()
	for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	print(d[k-1])

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,k = i2()
ans = []*100
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
input = lambda: sys.stdin.readline().rstrip()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, k = map(int, readline().split())
    res = dict()
    cnt = 0

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

    num = (cnt + 1) - k
    print(res[num])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(war[k-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

print(ko_yakusu[-K])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(l[k * -1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

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

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

Solution code:
import sys
A,B,K = map(int,input().split())
if not ( 1 <= A <= 100 and 1 <= B <= 100 ): sys.exit()
if not ( 1 <= K ): sys.exit()
#euclid algorithm
if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B
# B is greatest common divisor
count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break

Submission status: Accepted

Solution code:
import sys
A,B,K = map(int,input().split())
#euclid algorithm
if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B

count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
minnum = min(a,b)
maxnum = max(a,b)
lis = []
for mi in reversed(range(1,minnum+1)):
  if minnum % mi == 0 and maxnum % mi == 0:
    lis.append(mi)

print(lis[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
A, B, K = map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
divisors = make_divisors(math.gcd(A, B))
divisors.sort(reverse=True)
print(divisors[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        divisors.sort(reverse=True)
        return divisors

from sys import stdin
from math import gcd
def main():
    #入力
    readline=stdin.readline
    a,b,k=map(int,readline().split())

    c=gcd(a,b)
    li=make_divisors(c)

    print(li[k-1])

if __name__=="__main__":
    main()

Submission status: Accepted

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

l = []

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(anslist[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
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)
print(tmp[-k])

Submission status: Accepted

Solution code:
def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
  
A,B,K = (int(X) for X in input().split())
Count = 0
Divid = Div(min(A,B))
for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
 
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
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, k = rm()
t = math.gcd(a, b)
cnt = 0
for i in range(t, 0, -1):
  if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()