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:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, K = il()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import gcd

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]
    
a, b, k = map(int, input().split())
x = gcd(a, b)
l = make_divisors(x)
print(l[-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 = map(int,input().split())
list=[]
for i in range(1,101):
    if A%i==0 and B%i==0:
        list.append(i)
list.sort(reverse=True)
#print(list)
print(list[K-1])

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

Submission status: Accepted

Solution code:
import sys
import math

input = sys.stdin.readline

A,B,K = list(map(int,input().split()))
counter = []
num = 0
while num <101:
    num += 1
    if A %num ==0 and B % num ==0:
        counter.append(num)
    
print(counter[-K])

Submission status: Accepted

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

Submission status: Accepted

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

min = A if A <= B else B

list = []
for i in range(1, min+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())
mi = min(A, B)
l = []
for i in range(1, mi+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());count=0;m=min(a,b)
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:
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(list(reversed(l))[k-1])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def LI():return map(int,input().split())
def I(): return input().split()

a,b,k=LI()
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())
a=[x for x in range(1,A+1) if A%x==0 and B%x==0]
print(a[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

a, b, k = map(int, open(0).read().split())

g = gcd(a, b)

cd = []

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

print(cd[-k])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,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)
l=sorted(l)[::-1]
print(l[K-1])

Submission status: Accepted

Solution code:
def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1]


def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K]


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

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

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

cnt=0
s=min(a,b)

for i in range(s,0,-1):
  if a%i==0 and b%i==0:
    cnt+=1
    #print(i)
    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)
            break

Submission status: Accepted

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

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

print(yakusuu[-K])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
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]
A,B,K=map(int,input().split())
c=gcd(A,B)
print(make_divisors(c)[-K])

Submission status: Accepted

Solution code:
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]

a_d = set(make_divisors(a))
b_d = set(make_divisors(b))
d = sorted(list(a_d & b_d), reverse=True)

print(d[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(1,101):
  if A%n==0 and B%n==0:
    a.append(n)

print(a[-K])

Submission status: Accepted

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

M = min(A,B)
S = []

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

S=sorted(S)[::-1]
print(S[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())
lis=list()

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

print(lis[k-1])

Submission status: Accepted

Solution code:
import sys
import os
import math

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

C = min(A, B)
hairetu = []

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

print(hairetu[-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]


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


set_a = set(make_divisors(a))
set_b = set(make_divisors(b))

both = list(set_a & set_b)
both.sort()

print(both[- k])

Submission status: Accepted

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

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

Submission status: Accepted

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

num = min(a, b)

cnt = 0

while cnt < k:
    if a%num == 0 and b%num == 0:
        cnt += 1
        num -= 1
    else:
        num -= 1
print(num + 1)

Submission status: Accepted

Solution code:
import numpy as np

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

if __name__ == '__main__':
    A, B, K = map(int, input().split())
    N = make_divisors(np.gcd(A, B))
    N.sort(reverse=True)
    print(N[K-1])

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
            
resolve()

Submission status: Accepted

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

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

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())
r = gcd(a,b)
e = []
for i in range(1,r+1):
    if r%i == 0:
        e.append(i)
print(e[len(e)-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)
      break

Submission status: Accepted

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

a_y = set(make_divisors(a))
b_y = set(make_divisors(b))
#print(a_y & b_y)
y = list(a_y & b_y)
y.sort(reverse=True)
print(y[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,k=map(int,input().split())
g=math.gcd(a,b)
d=[]
for i in range(1,int(pow(g,0.5))+1):
  if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i)
d.sort(reverse=True)
print(d[k-1])

Submission status: Accepted

Solution code:
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


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


def LS(): return list(sys.stdin.readline().rstrip().split())


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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

D = [i for i in range(1,min(A, B)+1) if A % i == 0 and B % i == 0]

print(D[-K])

Submission status: Accepted

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

Submission status: Accepted

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

a,b,k=map(int,input().split())
g=gcd(a,b)
cnt=0
for i in range(g,0,-1):
    if g%i==0: cnt+=1
    if cnt==k:
        print(i)
        break

Submission status: Accepted

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
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,c=map(int,input().split())
n=math.gcd(a,b)
ans=make_divisors(n)
print(ans[-c])

Submission status: Accepted

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

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

Submission status: Accepted

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

while i > 0:
    if a % i == 0:
        if b % i == 0:
            c += 1

    if c == k:
        print(i)
        break

    i -= 1

Submission status: Accepted

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

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

lst=cf(a,b)
lst.insert(0,1)

print(lst[-k])

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]

Submission status: Accepted

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

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

print(li[-k])

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def main():
    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:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
    A, B, K = map(int, readline().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])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
m = min(a,b)
l = set()
for i in range(1,m+1):
  if a%i == 0 and b%i == 0:
    l.add(i)

print(sorted(list(l))[-k])

Submission status: Accepted

Solution code:
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    m = min(a, b)
    c = 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(2, 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 = []
if a > b:
  c = b
else:
  c = a

for i in range(1, c+1):
  if a % i == 0 and b % i == 0:
    ans.append(i)
  else:
    continue


print(ans[-k])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
t = 100
cnt = 0
while t > 0:
    if a%t == 0 and b%t == 0:
        cnt+=1
        if cnt == k: break
    t-=1
print(t)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
ans = 0
curr = min(A, B)
while K > 0:
    if A % curr == 0 and B % curr == 0:
        K -= 1
        ans = curr
    curr -= 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, k = map(int, open(0).read().split())


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


x = divisor(a)
y = divisor(b)
print(sorted(list(x & y), reverse=True)[k-1])

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


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


def LS(): return list(sys.stdin.readline().rstrip().split())


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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(AB[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

i = min(a,b)
ans = 0
while 1:
  if not(a % i)  and not(b % i):
    ans += 1
  if ans == k:
    break
  i -= 1

print(i)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
if A > B:
    num = A
    A = B
    B = num
flag = 0
count = 0
el = []
for i in range(1,A+1):
    if A % i == 0 and B % i == 0:
        el.append(i)


print(el[-K])

Submission status: Accepted

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

def main():
    A, B, K = mi()
    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())

Min=min(a,b)

l=[]

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

#print(l)

print(l[k-1])

Submission status: Accepted

Solution code:
def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

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

    return common_divisors[-k]

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

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

A_B_and_set = set(A_yaku) & set(B_yaku)
A_B_and_list = list(A_B_and_set)

ans_list=sorted(A_B_and_list,reverse=True)

ans=ans_list[K-1]
print(ans)

Submission status: Accepted

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

def main(a,b,k):
    ans=0
    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__':
    a,b,k=readinput()
    ans=main(a,b,k)
    print(ans)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

l = []
for i in range(1,101):
  if a % i == b % i == 0:
    l.append(i)
    
l.sort()
print(l[(-1)*k])

Submission status: Accepted

Solution code:
# abc120_b.py
import fractions 
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

A, B, K = map(int,input().split())
cnt = 0
_max = gcd(A,B)
while _max>=0:
    if A%_max==0 and B%_max==0:
        cnt += 1
        if cnt == K:
            print(_max)
            exit()
    _max -=1

Submission status: Accepted

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

Submission status: Accepted

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

loop = min(A,B)
ans = []

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

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

Submission status: Accepted

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

div = []

for i in reversed(range(1, 101)):
    if A%i == 0 and B%i ==0:
        div.append(i)

print(div[K-1])

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
chk = 0
i = 100
while i > 0:
    if a%i==0 and b%i==0:
        chk += 1
        if chk == k:
            print(i)
            exit()
        else:
            pass
    i -= 1

Submission status: Accepted

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

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