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:
from typing import Set


def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs


def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k]


def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
integer1, integer2, term = map(int, input().split())
term_value = max(integer1, integer2)
largest_term = 0
while term_value <= 100:
    if integer1 % term_value == 0 and integer2 % term_value == 0:
        largest_term += 1
    if term == largest_term:
        break
    term_value -= 1
print(term_value)

Submission status: Accepted

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[]
    for i in range(1,l[1]+1):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Submission status: Accepted

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

def ans120(A:int, B:int, K:int):
    if A>=B:
        n=A
    else:
        n=B
    ans_list=[]
    for i in range(1,n+1):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Submission status: Accepted

Solution code:
int1, int2, rank = map(int, input().split())
kouyaku_list = []
for i in range(1, 100 + 1):
    if int1 % i == 0 and int2 % i == 0:
        kouyaku_list.append(i)

print(kouyaku_list[-rank])

Submission status: Accepted

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

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

print(i)

Submission status: Accepted

Solution code:
import math

num1, num2, target = map(int, input().split())

number = math.gcd(num1, num2)

table = []
for j in range(1, number+1):
    if number % j == 0:
        table.append(j)
list.sort(table, reverse=True)

print(table[target-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
A,B,K= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
wari=min(A,B)
while True:
    if A%wari==0 and B%wari==0:
        count+=1
    if count==K:
        print(wari)
        exit()
    wari-=1

Submission status: Accepted

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

Submission status: Accepted

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

print(A[k-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = list(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 = set(table)
    return table
ablist = sorted(list(divisor(a) & divisor(b)),reverse=True)
print(ablist[k-1])

Submission status: Accepted

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

g = gcd(a, b)

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1

Submission status: Accepted

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

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

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

a_divisor = divisor(A)
b_divisor = divisor(B)

print(sorted(list(set(a_divisor) & set(b_divisor)), reverse=True)[K-1])

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

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

Submission status: Accepted

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))
  

def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b)


def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k])

main()

Submission status: Accepted

Solution code:
def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i)

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

w_list=[]

num=min(a,b)+1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 10.09.2020 08:12:15

import sys

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

cnt = 0

ls = []

for k in range(1, max(A, B) + 1):
    if (A % k == 0) & (B % k == 0):
        cnt += 1
        ls.append(k)

print(ls[-K])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(1, 200):
    if(a%i == 0 and b%i == 0):
        cnt = cnt + 1;

cnts = cnt - k + 1
cnt = 0
for i in range(1, 200):
    if(a%i == 0 and b%i == 0):
        cnt = cnt + 1;
    if(cnt == cnts):
        print(i)
        break

Submission status: Accepted

Solution code:
import math

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

c=math.gcd(a,b)

d=[i for i in range(1,c+1) if c%i==0]

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

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
ct = 0
for i in range(101,0,-1):
    if (A % i == 0) & (B % i == 0):
        ct += 1
        if ct == K:
            break

print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break
if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break

Submission status: Accepted

Solution code:
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


cnt = 0
a, b, k = map(int, input().split())
for num in range(max(a, b), -1, -1):
    if a % num == 0 and b % num == 0:
        cnt += 1
        if k == cnt:
            print(num)
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
c = []
for i in range(1, 100 + 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())
count = 0
ans = []
for i in range(1, 10001):
  if a%i == 0 and b%i == 0:
    count += 1
    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=ans[::-1]
print(ans[K-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n=len(p)
print(p[n-k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, K = LI()

    d = math.gcd(A, B)
    ans = 0
    for i in range(d, 0, -1):
        if A % i == B % i == 0:
            K -= 1
        if K == 0:
            ans = i
            break

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

C = min(A, B)

cnt = 0

while(1):
    if(A % C == 0 and B % C == 0):
        cnt+=1
    if(cnt == K):
        print(C)
        exit()
    C -= 1

Submission status: Accepted

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

a,b,k = map(int,input().split())
ans = gcd(a,b)
cnt = 1
while cnt < k:
    ans -= 1
    if a % ans == 0 and b % ans == 0:
        cnt += 1
print(ans)

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))
set_ab = set_a.intersection(set_b)

list_ab = list(set_ab)
list_ab.sort()
# print(list_ab)

print(list_ab[-K])

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:
from math import gcd

a, b, k = list(map(int, input().split()))
g = gcd(a, b)
l = []
i = 1
while i * i <= g:
    if g % i == 0:
        l.append(i)
        if i != g // i:
            l.append(g // i)
    i += 1
l.sort()
print(l[-k])

Submission status: Accepted

Solution code:
import math
A,B,M = map(int,input().split())
C = math.gcd(A,B)
ls = []
for i in range(1,101):
    if C % i == 0:
        ls.append(i)
ls.sort()
print(ls[-M])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, k = M()
x = ans = 0
for i in range(101, 0, -1):
    if a%i == 0 and b%i == 0:
        x += 1
    if k == x:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
#
# abc120 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output)


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

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


if __name__ == "__main__":
     # unittest.main()
     resolve()

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


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

Submission status: Accepted

Solution code:
import math
A,B,K=map(int,input().split())
anslist=[]
for i in range(1,max(A,B)+1):
    if (A%i==0)&(B%i==0):
        anslist.append(i)
print(anslist[0-K])

Submission status: Accepted

Solution code:
from math import *
a,b,k=map(int,input().split())
g=gcd(a,b)
for i in range(g,0,-1):
    if(g%i==0):
        k-=1
    if(k==0):
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table
A, B, K = map(int, input().split())
res = divisors(A) & divisors(B)
res = list(res)
res.sort()
print(res[-K])

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split()) 
n = min(a,b)
ans = []
for i in range(1, n+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 =map(int,input().split())
count = 0
for i in range(a,0,-1):
    if a % i == 0:
        if b % i == 0:
            count += 1
            if count == k:
                print(i)
                sys.exit()

Submission status: Accepted

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

c=min(a,b)
d=max(a,b)
ans=[]

for i in range(c):
    if c%(i+1)==0 and d%(i+1)==0:
        ans.append(i+1)
            
print(ans[-k])

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
lst = []
end = min(a,b) #実際の終わり

for i in range(1,end+1):
    ra = a % i
    rb = b % i
    if ra == 0 and rb == 0:
        lst.append(i)

ans = lst[-1*k]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(vec[-K])
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list = []

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

print(list[-K])

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def euclidean(a,b):
  _ = a % b
  if _ == 0:
    return b
  else:
    while 1:
      if b % _ == 0 :
        break
      else:
        _ = b % _
    return _
  
A, B, K = map(int, input().split())
 
a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
by = []
r = int(e ** (1 / 2))
 
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

Submission status: Accepted

Solution code:
import math

def make_divisors(n):
    #https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
    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())
tmp = math.gcd(a,b)
ans = make_divisors(tmp)
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(l[-k])

Submission status: Accepted

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

min = a
if b < min:
  min = b

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

ans_lists.reverse()
ans = ans_lists[k-1]

print(ans)

Submission status: Accepted

Solution code:
A,B,K=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)
C.sort()
print(C[len(C)-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())
X = []
for i in range(1, min(A, B) + 1):
  if A % i == 0 and B % i == 0:
    X.append(i)
print(X[-K])

Submission status: Accepted

Solution code:
import math

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

for i in range(math.gcd(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:
import math

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

d = math.gcd(a, b)

e = d + 1
l = 0
while True:
    e -= 1
    if d % e == 0:
        l += 1
        if l == k:
            break


print(e)

Submission status: Accepted

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

g = math.gcd(a,b)
c = 0
i = 1
for i in range(g,0,-1) :
    if g%i == 0 :
        c+=1
        if c==k :
            break
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
a, b, k = [int(num) for num in lines.pop(0).split(" ")]
count = 0
for n in range(min(a, b), 0, -1):
    if (a % n == 0) and (b % n == 0):
        count += 1
    if count == k:
        break
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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())
l=[]
for i in range(1,101):
    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())
print([i for i in range(1, 1+min(a, b)) if a%i==0 and b%i==0][-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(sorted(l, reverse=True)[k-1])

Submission status: Accepted

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

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

print(D[-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_yakusu = make_divisors(a)
b_yakusu = make_divisors(b)
ab_yakusu = sorted(set(a_yakusu) & set(b_yakusu), reverse=True)

print(ab_yakusu[k-1])

Submission status: Accepted

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

com_dev = [1]

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

print(com_dev[len(com_dev) - 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(' '))

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

print(common_divisor[K-1])

Submission status: Accepted

Solution code:
def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k])

if __name__ == '__main__':
    abc120_b()

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
ans = []
# 大きいほうからK番目を判定する。
for i in range(1, 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, a*b+1):
    if a % i == 0 and b % i == 0:
        ans.append(i)
print(ans[-k])

Submission status: Accepted

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

import math
print(sorted(make_divisors(math.gcd(a,b)),reverse=True)[k-1])