Problem:


Score : 200 points

Problem Statement

You are given positive integers A and B.

Find the K-th largest positive integer that divides both A and B.

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

1 \leq A, B \leq 100

The K-th largest positive integer that divides both A and B exists.

K \geq 1

Input

Input is given from Standard Input in the following format:

A B K

Output

Print the K-th largest positive integer that divides both A and B.

Sample Input 1

8 12 2

Sample Output 1

2

Three positive integers divides both 8 and 12: 1, 2 and 4.
Among them, the second largest is 2.

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1



Sample input:
8 12 2


Sample output:
2

Submission status: Accepted

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

count.sort(reverse= True)
#print(count)

print(count[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

data = []

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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)
list = sorted(list,reverse = True)
#print(list)
print(list[K-1])

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict

#key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

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

A_list = list()
B_list = list()
all_list = list()
for a in range(A):
    if A%(a+1) == 0:
        A_list.append(a+1)
    
for b in range(B):
    if B%(b+1) == 0:
        B_list.append(b+1)

for a in A_list:
    for b in B_list:
        if a == b:
            all_list.append(a)
all_list.sort(reverse=True)
print(all_list[K-1])            
# m_list = list()

Submission status: Accepted

Solution code:
def gcd(x, y):
  while(y):
    x, y = y, x % y
  return x
a, b, k = map(int, input().split())
g = gcd(a, b)
dlist = []
for i in range(1, g + 1):
  if (g % i == 0):
    dlist.append(i)
dlist.sort(reverse=True)
print(dlist[k - 1])

Submission status: Accepted

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

Submission status: Accepted

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

nums = list(range(101))
nums.reverse()

for i in nums:
    a = A%i
    b = B%i
    
    if a == 0 and b == 0:
        count += 1
    
    if count == K:
        print(i)
        break

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
if A < B :
    A,B = B,A
cnt = 0
L = []
for i in range(1,10**4+1) :
    if (A%i == 0) and (B%i == 0) :
        L.append(i)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    print(result_list[-1*K])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = set()
b = set()

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

for i in range(1,max(A,B) + 1):
  if A % i == 0: a.add(i)
  if B % i == 0: b.add(i)

c = sorted(list(b.intersection(a)),reverse=True)

print(c[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:
import fractions
A,B,K =map(int,input().split())
tmp = fractions.gcd(A,B)
l =[]
for i in range(tmp):
    if tmp % (i+1) == 0:
        l.append(i+1)
print(l[-K])

Submission status: Accepted

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

r=[]

if a>b:
  c=range(1,a+1)
else:
  c=range(1,b+1)

for x in c:
  if a % x==0 and b%x==0:
    r.append(x)

print(r[-1*k])

Submission status: Accepted

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

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


print(ans[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
x = [x for x in range(1,a+1) if a % x == 0]
x.sort(reverse=True)
y = [x for x in range(1,b+1) if b % x == 0]
y.sort(reverse=True)

cnt = 0
for i in range(len(x)):
    if x[i] in y:
        cnt += 1
    if cnt == k:
        print(x[i])
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int, input().split())
c=0
for j in range(max(a,b)):
    i=max(a,b)-j
    #print(i,a % i==0 , b % i==0)
    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())
cnt=0
ans=[]
for i in range(1,101):
    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())
count = 0
for i in reversed(range(1, min([A, B])+1)):
    if (A // i) * i == A and (B // i) * i == B:
        count += 1
        if count == K:
            print(i)

Submission status: Accepted

Solution code:
class FutureMath:
    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    def gcd_(self, list):
        result = list[0]
        for el in list[1:]:
            result = self.gcd(result, el)
        return result

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

    def lcm_(self, list):
        result = list[0]
        for el in list[1:]:
            result = self.lcm(result, el)
        return result

    def cds(self, n):
        result = list()
        for i in range(1, n+1):
            if n % i == 0:
                result.append(i)
        return result


fm = FutureMath()

if __name__ == "__main__":
    a, b, k = map(int, input().split())
    gcd = fm.gcd(a, b)
    cds = fm.cds(gcd)
    print(cds[-k])

Submission status: Accepted

Solution code:
from sys import stdin

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

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

input = lambda: stdin.readline()
main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,k=IL()
c=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        c.append(i)
print(c[-k])

Submission status: Accepted

Solution code:
p = input().split()
a = int(p[0])
b = int(p[1])
k = int(p[2])
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:
def solve():
  A, B, K = map(int, input().split())
  k = 0
  for i in range(100, 0, -1):
    if A % i != 0 or B % i != 0: continue
    k += 1
    if K == k: return i

print(solve())

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import bisect
from datetime import datetime as dt

A, B, K = map(int, raw_input().split())
max = max(A, B)
a = []

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

DivList = []

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
dd = min([a,b])
kcnt = 0
while True:
  if a % dd == 0 and b % dd == 0:
    kcnt += 1
    if kcnt == k:
      print(dd)
      exit(0)
  dd -= 1

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
x = 1
y = 100
while x <= K:
  if A%y == 0 and B%y == 0 and x != K:
    x += 1
    y -= 1
  elif A%y == 0 and B%y == 0 and x == K:
    print(y)
    break
  else:
    y -= 1

Submission status: Accepted

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

Submission status: Accepted

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

q.sort(reverse=True)

print(q[K-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
multi_input = lambda dtype: list(map(dtype,input().split()))
(A,B,K) = multi_input(int)
n = K
i = min(A,B) + 1
while n > 0:
    i -= 1
    if A % i ==0 and B % i ==0:
        n -= 1
print(i)

Submission status: Accepted

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

print(arr[-c])

Submission status: Accepted

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

ans =[]
dai = 0
if a>b:
    dai = a
else:
    dai = b
for i in range(1,dai+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())
count = 0
for i in range(0,a):
    j = a - i
    if a % j ==0 and b % j == 0:
        count = count + 1
        if count == k:
            result = j
            break

print(result)

Submission status: Accepted

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

a, b, k = map(int, input().split())
cou = 0
if a > b:
    a, b = b, a

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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


A, B, K = map(int, input().split())
cnt = 0
gc = gcd(A, B)

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

Submission status: Accepted

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

num = []

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

print(num[-k])

Submission status: Accepted

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

    a_set = set([a for a in range(1, A+1) if A % a == 0])
    b_set = set([b for b in range(1, B+1) if B % b == 0])

    ab = list(a_set & b_set)
    ans = sorted(ab, reverse=True)[K-1]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(max(a[0],a[1]),0,-1):
    if a[0] % i == 0 and a[1] % i == 0:
        a[2] = a[2] - 1
        if a[2] == 0:
            print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

A = []
x = gcd(a, b)
for i in range(1, x + 1):
    if x % i == 0:
        A.append(i)
        
A.reverse()

print(A[k - 1])

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans[-K])

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

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

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(div[len(div) - K])

Submission status: Accepted

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

d_list = []
d = min(A, B)
while d > 0:
    if A % d == 0 and B % d == 0:
        d_list.append(d)
    d -= 1

print(d_list[K - 1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = 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()
print(ans[-k])

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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[::-1][K-1])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
cnt = 0
res = 1
res_array = []
while res <= max(a, b):
    if a % res == 0 and b % res == 0:
        res_array.append(res)
        cnt += 1
    res += 1
print(res_array[-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:
# https://atcoder.jp/contests/abc120/tasks/abc120_b

import itertools
import collections
import bisect

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())  # 複数数値入力

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

    if c == 0:
        print(i + 1)
        break

Submission status: Accepted

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

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[len(L)-K])

Submission status: Accepted

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

Submission status: Accepted

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

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

print( divide + 1 )

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())

A, B, K = inpl()
cd = []

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ret = list()
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        ret.append(i)
ret = list(reversed(ret))
print(ret[k - 1])

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

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
A=[i for i in range(101)][::-1]
for i in A:
  if a%i==b%i==0:
    po=i
    break
B=[]
for i in range(1,int(po**(1/2)+1)):
  if po%i==0:
    B.append(i)
    B.append(po//i)
B=list(set(B))
B.sort()
print(B[-k])

Submission status: Accepted

Solution code:
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    a, b, k = ip.IL()

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


main()

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

C = gcd(A,B)
l = [i for i in range(1,min(A,B)+1) if C % i == 0]
print(l[-K])

Submission status: Accepted

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


list1 = []
list2 = []

for i in range(1,a+1):
  if a % i == 0:
    list1.append(i)
    
for i in range(1,b+1):
  if b % i == 0:
    list2.append(i)
li = sorted(list(set(list2) &set(list1)),reverse=True)
print(li[k-1])

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

index = 0

mx = max(a, b)

while(mx != 0):
    if a % mx == 0 and b % mx == 0:
        index += 1
    if index == k:
        break
    mx -= 1
print(mx)

Submission status: Accepted

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

    for i in range(100):
        i = 100 - i
        if a % i == 0 and b % i == 0:
            if k == 1:
                print(i)
                return
            k -= 1


if __name__ == '__main__':
    main()