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= [int(i) for i in input().split()]

c = []

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

print(c[k-1])

Submission status: Accepted

Solution code:
def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z

nums=list(map(int,input().split(" ")))
g=gcd(nums[0],nums[1])
arr=[0 for i in range(100)]
a=0
for i in range(100):
    i+=1
    if nums[0]%i==0 and nums[1]%i==0:
        arr[a]=i
        a+=1
        if i==g:
            print(arr[a-nums[2]])
            break

Submission status: Accepted

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

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

print(cd[-(k)])

Submission status: Accepted

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

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:
int_list = input().split()

a = int(int_list[0])
b = int(int_list[1])
k = int(int_list[2])

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

Submission status: Accepted

Solution code:

# coding: utf-8

# In[26]:


import sys


# In[106]:


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


# In[107]:


def yakusuu(x):
    yakusuu_array = []

    for i in range(1, x+1):
        if x % i == 0:
            yakusuu_array.append(i)
    
    return yakusuu_array


# In[108]:


y_list = sorted(list(set(yakusuu(A)) & set(yakusuu(B))), reverse=True)


# In[109]:


print(y_list[K-1])

Submission status: Accepted

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

divisorA = [ i for i in range(1,a+1 ) if a % i == 0 ]
divisorB = [ i for i in range(1,b+1 ) if b % i == 0 ]

divisor = []

for elemA in divisorA:
	divisor += filter(lambda elem: elem == elemA, divisorB)	

divisor = sorted(divisor)
divisor = divisor[::-1]
# print(divisor)

print( divisor[k-1] )

Submission status: Accepted

Solution code:
A, B, K = list(map(int, input().split()))
nums = []
for n in range(1, max(A, B)+1):
    if A % n == 0 and B % n == 0:
        nums.append(n)

print(nums[-K])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
A, B, C = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
i=1
count = 0
x=[]
for i in range(101):
  try:
    if a%i==0 and b%i==0:
      count+=1
      x.append(i)
  except ZeroDivisionError:
    pass
  i+=1
print(x[-c])

Submission status: Accepted

Solution code:
inp = list(map(int,input().split(" ")))
i = min(inp[0],inp[1])
k_=0
k_list = list()
for k in range(1,i+1):
    if inp[0]%k ==0:
        if inp[1]%k==0:
            k_+=1
            k_list.append(k)
print(k_list[-inp[2]])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,K = map(int, lines.pop(0).split(' '))
    x = min(A,B)
    res = []
    for i in range(x,0,-1):
        if A%i == 0 and B%i == 0:
            res.append(i)
    print(res[K-1])

lines = [x.strip() for x in sys.stdin.readlines()]                                                                                                            
                                                                                                                                                              
#                                                                                                                                                             
# solve !!                                                                                                                                                    
#                                                                                                                                                             
solve(lines)

Submission status: Accepted

Solution code:

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

count = 0
i = 1

ans = []
while i <= a and i <= b:
    if a % i == 0 and b % i == 0:
        ans.append(i)
    i += 1


print(ans[-k])

Submission status: Accepted

Solution code:
import fractions


def main():
    a = list(map(int, input().split()))
    b = fractions.gcd(a[0], a[1])
    c = b
    for i in range(a[2]-1):
        while True:
            c -= 1
            if b % c == 0:
                break
    print(c)


main()

Submission status: Accepted

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

Submission status: Accepted

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

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


print(divs[-K])

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
i = 1
dividable_numbers = []
while True:
    if a % i == 0 and b % i == 0:
        count += 1
        dividable_numbers.append(i)

    if a < i or b < i:
        break

    i += 1

print(dividable_numbers[-k])

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
cand = []
denom = 0

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

print(cand[-K])

Submission status: Accepted

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


import sys
import math

# 1整数
# n = int(input())

# 空白区切り2整数
a, b, k = list(map(int, input().split()))

# 空白区切りリスト
# a=list(map(int, input().split()))
count = 0
num = min(a, b) + 1
while count < k:
    num -= 1
    if a % num == 0 and b % num == 0:
        count += 1

print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

A,B,K  = map(int, input().split(" "))
count = 0
i = 1
tempList = []
for i in range(1,200) :
    if A%i == 0 and B%i == 0:
        tempList.append(i)
print(tempList[-K])

Submission status: Accepted

Solution code:
a=input()
A=int(a.split()[0])
B=int(a.split()[1])
K=int(a.split()[2])

a=0
if(A>B): i=A
else: i=B
count=0
while(a==0):
  if(A%i==0 and B%i==0):
    count+=1
    if(count==K):
      print(i)
      break
  i-=1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int,input().split())
a_div = []
b_div = []
for i in range(1, a + 1, 1):
  if a % i == 0:
    a_div.append(i)
for i in range(1, b + 1, 1):
  if b % i == 0:
    b_div.append(i)
common_div = []
common_div = set(a_div) & set(b_div)
common_div_lst = list(common_div)
common_div_lst.sort(reverse = True)
print(common_div_lst[k - 1])

Submission status: Accepted

Solution code:
a,b, c = map(int, input().split())
turn_a =[x for x in range(1,a+1)]
turn_b=[y for y in range(1,b+1)]
ans=[x for x,y in zip(turn_a,turn_b) if a%x==0 and b%y==0]
ans.reverse()
print(ans[c-1])

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# ABC120: B
import sys
sys.setrecursionlimit(10000)

input = sys.stdin.readline

def debug(*args, **kdws): print(*args, file=sys.stderr, **kdws)

A, B, K = [int(x) for x in input().split()]
debug("*******")
debug(A, B, K)
c = 0

div = []
for i in range(1, max(A, B)+1):
    #debug(A, B, i, "c=",c, ", A%i=",  A%i, ",B%i=", B%i)
    if A % i == 0 and B % i == 0:
        div.append(i)
debug(div)
print(div[-K])
debug("*******")

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
ans=[1]
for i in range(2,int(max([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:
a, b, k = map(int, input().split())
print([j for j in [i for i in range(1, 101) if a % i == 0] if b % j == 0][-k])

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
s=set()
x=1
while(x*x<=a):
  if(a%x==0):
    s.add(x)
  if(a//x!=x and a%(a//x)==0):
    s.add(a//x)
  x+=1
x=1
while(x*x<=b):
  if(b%x==0):
    s.add(x)
  if(b//x!=x and b%(b//x)==0):
    s.add(b//x)
  x+=1
s=list(sorted(s))
s.sort(reverse=True)
count=0
for i in range(len(s)):
    if(a%s[i]==0 and b%s[i]==0):
        count+=1
    if(count==k):
        print(s[i])
        exit()

Submission status: Accepted

Solution code:
a, b, k = list(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:
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    d = a % b
    if d == 0:
        return b
    return gcd(b, d)

def divisors(d):
    ret = []
    for a in range(1, d + 1):
        if d % a == 0:
            ret.append(a)
    return ret

l = raw_input().split()
a = int(l[0])
b = int(l[1])
k = int(l[2])

d = gcd(a, b)
ret = divisors(d)

print(ret[-k])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = list(map(int,input().split()))
count = 0
for i in range(min(N[0],N[1]),-1,-1):
  if count>N[2]:
    break
  elif i!=0 and N[0]%i==0 and N[1]%i==0:
#    ans.append(i)
    count+=1
  if count==N[2]:
    print(i)
    count+=1

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
a, b, k = [int(x) for x in stdin.readline().rstrip().split()]
divides=[]
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        divides.append(i)
divides.sort(reverse=True)
print(divides[k-1])

Submission status: Accepted

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

smaller = min(A, B)

lst = []
cnt = 1 
for i in range(1, smaller+1, 1):
  if A % i == 0 and B % i == 0:
    lst.append(i)
sorted_lst = sorted(lst,reverse=True)

print(sorted_lst[K-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a,b,k = list(map(int,input().split()))
lw = min(a,b)
for i in range(lw,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())
count = min(a, b)
flag = 0
while True:
    if a % count == 0 and b % count % count == 0:
        flag += 1
        if flag == k:
            print(count)
            break
    count -= 1

Submission status: Accepted

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

Submission status: Accepted

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

st = max(A, B)
cnt = 0
for i in range(st)[::-1]:
    j = i + 1
    if (A%j==0) & (B%j==0):
        cnt += 1
    if cnt == K:
        ans = j
        break

print(ans)

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())
cnt = 0
ans = 0
for i in range(gcd(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        cnt += 1
        ans = i
    if cnt == K:
        print(ans)
        break
    i += 1

Submission status: Accepted

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

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

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

ans = []
while(N != 0):
    M, N = N, M%N
s = 0
MAX = M + 0
current = 0
for i in range(1,101):
    if M%i == 0:
        ans.append(int(i))
ans.sort(reverse=True)
print(ans[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

print([i for i in range(100, 0, -1) if A%i == B%i == 0][K-1])

Submission status: Accepted

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

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

        if count == K:
            answer = i
            break

print(answer)

Submission status: Accepted

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

i=1
n=100

while i<=K:
  #print(i,n)
  if A%n == 0 and B%n ==0:
    if i==K:
      break
    else:
      i+=1
      n-=1
  else:
    n-=1
print(n)

Submission status: Accepted

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

for i in range(1, 101):
	x = a / i
	y = b / i
	if x.is_integer() == True and y.is_integer() == True:
		li.append(i)

sort_li = sorted(li, reverse=True)
print(sort_li[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

    c += 1

print(ans[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
ans = 0
count = 0
for i in range(100,0,-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())
l1 = [i for i in range(1, a+1) if (a % i == 0)]
l2 = [i for i in range(1, b+1) if (b % i == 0)]
l = list(set(l1) & set(l2))
l.sort(reverse = True)
print(l[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
if A>B:
  L=A
else:
  L=B
D = L

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

Submission status: Accepted

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

if A>B:
    for i in range(2,B+1):
        if A%i==0 and B%i==0:
            num.append(i)
            count =count+1
else:
    for i in range(2,A+1):
        if A%i==0 and B%i==0:
            num.append(i)
            count =count+1
#print(count)

print(num[count-K])

Submission status: Accepted

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

a = int(a)
b = int(b)
k = int(k)

#公約数
small = min(a,b)

list = []

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

order = len(list)-k

print(list[order])

Submission status: Accepted

Solution code:
A, B, K = (int(i) for i in input().split()) 
 
a = set()
b = set()
 
for i in range(1, A + 1):
    if A % i == 0:
        a.add(i)
 
for i in range(1, B + 1):
    if B % i == 0:
        b.add(i)

c = list(a & b)
c.sort()
c.reverse()
print(c[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

for i in range(len(al)):
    if al[i] in bl:
        cl.append(al[i])

print(cl[-k])

Submission status: Accepted

Solution code:
nums = [int(s) for s in input().split(' ')]
if nums[0]>nums[1]:
  a = nums[0]
  b = nums[1]
else:
  a = nums[1]
  b = nums[0]
c= nums[2]

while b>0:
  tmp = a%b
  a = b
  b = tmp

count=0
for i in range(a,0,-1):
  if a%i==0:
    count+=1
    if count==c:
      print(i)
      break

Submission status: Accepted

Solution code:
from sys import stdin

abk = [int(i) for i in stdin.readline().rstrip().split(" ")]

## seeds = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
commons = []
for i in range(1,max(abk[0],abk[1])+1):
    if (abk[0] % i) == 0 and (abk[1] % i) == 0:
        commons.append(i)
print(commons[-abk[2]])

Submission status: Accepted

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

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

Submission status: Accepted

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

divisor = min(a, b)
cnt = 0
while cnt != k:
    if int(a % divisor) == 0 and int(b % divisor) == 0:
        cnt = cnt + 1
    divisor = divisor - 1

print(divisor + 1)

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
x=0
y=[0]
c=min(a,b)

if a==1 or b==1:
    print(1)
    exit()
    
for d in range(1,c+1):
    if a%d==0 and b%d==0:
            y.append(d)

print(y[-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

cnt=0
num=1
N = []
while cnt<=100:
    if(A%num==0 and B%num==0):
        N.append(num)
    num += 1
    cnt += 1

print(N[-K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))

if l[0] < l[1]:
    mini = l[0]
else:
    mini = l[1]

ans_list = []
for i in range(1,mini+1):
    if l[0] % i == 0 and l[1] % i == 0:
        ans_list.append(i)

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

Submission status: Accepted

Solution code:
from fractions import gcd

def yakusuu(a):
    yakusuu = list()
    for i in range(1,a+1):
        if a % i == 0:
            yakusuu.append(i)
    return yakusuu

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

ans = yakusuu(gcd(A,B))[-K]
print(ans)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
divisor_list = []
for n in a, b:
    divisor_list.append(1)
    for i in range(2, n // 2 + 1):
        if n % i == 0:
            divisor_list.append(i)
    divisor_list.append(n)
l = sorted([x for x in set(divisor_list) if divisor_list.count(x) > 1], key=divisor_list.index)
print(l[-k])

Submission status: Accepted

Solution code:
a, b, k = list(map(int, input().split()))
div_a = [d for d in range(1, a+1) if a % d == 0]
div_b = [d for d in range(1, b+1) if b % d == 0]
common = sorted(list(set(div_a) & set(div_b)), reverse=True)
print(common[k-1])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
cnt = 0
for i in range(100, -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())
c = 1
res = 1
ass = [1]
while res != min(a,b):
    res += 1
    if a%res == 0 and b%res == 0:
        ass.append(res)
    
print(ass[len(ass)-k])

Submission status: Accepted

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

import sys

def gcd(a, b):

    c = min(a, b)
    d = max(a, b)
    r = 0    
    while True:
        r = d % c
        if r == 0:
            break
        d = c
        c = r

    return c


def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
 
    tokens = lines[0].split(" ")
    a = int(tokens[0])
    b = int(tokens[1])
    k = int(tokens[2])

    return (a, b, k)


def solve(a, b, k):

    tmp = gcd(a, b)

    div = tmp - 1
    order = 1
    current = tmp
    while div > 0:
        if order == k:
            break

        if tmp % div == 0:
           order += 1
           current = div

        div -= 1

    return current

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()

Submission status: Accepted

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

o.sort(reverse=True)
print(o[k-1:k][0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
if a > b:
    t = a
    a = b
    b = t
# 0<a<b<100
fact = []
for i in range(1,a+1,):
    if a%i==0 and b%i==0:
        fact.append(i)
print(fact[-k])

Submission status: Accepted

Solution code:

def divisor_list(n):
    i=1
    l=[]
    while i<=n:
        if n%i == 0:
            l.append(i)
        i = i+1
    return l


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


s1 = set(divisor_list(a))
s2 = set(divisor_list(b))
s3 = list(s1 & s2)
s3.sort(reverse=True)
print(s3[k-1])

Submission status: Accepted

Solution code:
def factorize(n):
    n_list = []
    for i in range(n):
        x = i + 1
        if n % x == 0:
            n_list.append(x)
    return n_list


if __name__ == '__main__':
    A, B, C = input().split()
    a_list = factorize(int(A))
    b_list = factorize(int(B))
    and_list = list(set(a_list) & set(b_list))
    and_list.sort(reverse=True)
    print(and_list[int(C) - 1])

Submission status: Accepted

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 
a,b,k = map(int, sys.stdin.readline().rstrip().split())
 
ans = []
 
for i in range(1, min(a,b)+1):
  if (a % i == 0) and (b % i == 0):
    ans.append(i)
 
print(ans[k*(-1)])

Submission status: Accepted

Solution code:
def main():
  A, B, K = map(int, input().split(" "))
 
  i = 1
  result = []
  while i <= min(A, B):
    if A % i == 0 and B % i == 0:
      result.append(i)
    i += 1
  print(result[-K])
  
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==0 and b%i==0): ans.append(i)
print(ans[-k])

Submission status: Accepted

Solution code:
from sys import stdin


def b(input_string):
    a, b, k = [int(x) for x in input_string.split()]
    mod_0_numbers = []
    if a >= b:
        for i in range(1, a+1):
            if a % i == 0:
                if b % i == 0:
                    mod_0_numbers.append(i)
    else:
        for i in range(1, b+1):
            if b % i == 0:
                if a % i == 0:
                    mod_0_numbers.append(i)
    return mod_0_numbers[-k]


def main():
    input_line = stdin.readline().rstrip()
    answer = b(input_line)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
memo = []

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

Submission status: Accepted

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

Submission status: Accepted

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

list_a = []
i = 1
while True:
    tmp1 = a % i
    tmp2 = b % i
    if tmp1 == 0 and tmp2 == 0:
        list_a.append(i)
    i += 1
    if a < i or b < 0:
        break
print(list_a[-1*(c)])

Submission status: Accepted

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

for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        lis.append(i)
    else:
        pass

print(lis[-(K)])

Submission status: Accepted

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

l = []

greatest = a

if(b > a):
  greatest = b
  
for i in range(1, (greatest + 1)):
  if(a % i == 0 and b % i == 0):
    l.append(i)
    
print(str(l[len(l) - int(k)]))

Submission status: Accepted

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

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

if(a < b):
  tmp = a
  a = b
  b = tmp
  
#a > b 
if(k > 1):
 for i in range(b+1):
  if(i != 0):
   if((a%i == 0)and(b%i == 0)):
    G.append(i)
 #print(G)
 print(G[-k]) 
elif(k == 1):
  print(gcd(a,b))

Submission status: Accepted

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

S = [1]

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

S.sort(reverse=True)

print(S[K-1])

Submission status: Accepted

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

n = A if A < B else B
k = 1

for i in range(n):
    if A % n == 0 and B % n == 0:
        if k == K:
            print(n)
        k += 1
    n -= 1

Submission status: Accepted

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

print(c[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input().split(' ')
y = 0
i = 0
ans = []
while y < int(x[0]) and y < int(x[1]):
    y += 1
    if int(x[0]) % y == 0 and int(x[1]) % y == 0:
        ans.append(y)
        i += 1
print(ans[len(ans) - int(x[2])])

Submission status: Accepted

Solution code:
a,b,k = [int(x) for x in input().split()]
an = [x for x in range(1,101) if a%x == 0]
bn = [x for x in range(1,101) if b%x == 0]
res = list(set(an)&set(bn))
res.sort()
print(res[-k])

Submission status: Accepted

Solution code:
# coding: utf-8

A, B, K = map(int, input().split())
flag = [False] * max(A, B)

for i in range(len(flag)):
    if (A % (i + 1) == 0) and (B % (i + 1) == 0):
        flag[i] = True
cnt = 0
answer = 0
for i, f in reversed(list(enumerate(flag))):
    if f:
        cnt += 1
        if cnt == K:
            answer = i + 1
            break

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import fractions

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

gcd_num = fractions.gcd(A, B)

if K==1:
    print(gcd_num)
    exit()

yakusuu_array = []
for i in range(1,gcd_num):
    if gcd_num % i == 0:
        yakusuu_array.append(i)
        yakusuu_array.sort(reverse=True)

print(yakusuu_array[K-2])

Submission status: Accepted

Solution code:
import fractions

A, B, K = map(int, input().split())
g = fractions.gcd(A, B)
if K == 1:
    print(g)
else:
    count = 1
    for i in range(g // 2, 0, -1):
        if g % i == 0:
            count += 1
        if count == K:
            print(i)
            break

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
yaku_A = []
yaku_B = []
for i in range(1,A):
    if A % i == 0:
        yaku_A.append(i)
for j in range(1,B):
    if B % j == 0:
        yaku_B.append(j)
yaku_A.append(A)
yaku_B.append(B)
kou = list(set(yaku_A) & set(yaku_B))
kou.sort()
print(kou[-K])

Submission status: Accepted

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

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

Submission status: Accepted

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