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: Runtime Error

Solution code:
# coding:utf-8


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

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

a, b, k = map(int, input().split())
gcd = math.gcd(a, b)
divisor_list = []

if gcd == 1:
    divisor_list = [1]
else:
    divisor_list.append(1)
    for i in range(2, gcd // 2 + 1):
        if gcd % i == 0:
            divisor_list.append(i)
    divisor_list.append(gcd)

print(divisor_list[len(divisor_list)-1-k+1])

Submission status: Runtime Error

Solution code:
def largest_common_divisor(a,b):
    if a==b: return a
    elif a>b:
        tmp = 1
        while tmp!=0:
            tmp = a%b
            a = b
            b = tmp
        return a
    elif a<b:
        tmp = 1
        while tmp!=0:
            tmp = b%a
            b = a
            a = tmp
        return b
if __name__=="__main__":
    A, B, K = map(int, raw_input().split())
    largest = largest_common_divisor(A,B)
    count = 0
    ans = 0
    for i in range(1,largest+1):
        if largest%i==0:
            count+=1
            if count == K:
                ans = i
                break
    print(ans)

Submission status: Runtime Error

Solution code:
def largest_common_divisor(a,b):
    if a==b: return a
    elif a>b:
        tmp = 1
        while tmp!=0:
            tmp = a%b
            a = b
            b = tmp
        return a
    elif a<b:
        tmp = 1
        while tmp!=0:
            tmp = b%a
            b = a
            a = tmp
        return b
if __name__=="__main__":
    A, B, K = map(int, raw_input().split())
    largest = largest_common_divisor(100,20)
    count = 0
    ans = 0
    for i in range(1,largest+1):
        if largest%i==0:
            count+=1
            if count == 3:
                ans = i
                break
    print(ans)

Submission status: Runtime Error

Solution code:
def largest_common_divisor(a,b):
  if a==b: return a
  elif a>b:
    tmp = 1
    while tmp!=0:
      tmp = a%b
      a = b
      b = tmp
    return a
  elif a<b:
    tmp = 1
    while tmp!=0:
      tmp = b%a
      b = a
      a = tmp
    return b
if __name__=="__main__":
  A, B, K = map(int, raw_input().split())
  largest = largest_common_divisor(A,B)
  count = 0
  ans = 0
  for i in range(1,largest+1):
    if largest%i==0:
        count+=1
        if count == 3:
            ans = i
            break
print(ans)

Submission status: Runtime Error

Solution code:
def largest_common_divisor(a,b):
  if a==b: return a
  elif a>b:
    tmp = 1
    while tmp!=0:
      tmp = a%b
      a = b
      b = tmp
    return a
  elif a<b:
    tmp = 1
    while tmp!=0:
      tmp = b%a
      b = a
      a = tmp
    return b
if __name__=="__main__":
  largest = largest_common_divisor(A,B)
  count = 0
  ans = 0
  for i in range(1,largest+1):
    if largest%i==0:
        count+=1
        if count == K:
            ans = i
            break
print(ans)

Submission status: Runtime Error

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

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

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k])

Submission status: Runtime Error

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

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

for k in da:
    if k in db:
    	dc.append(k)

dc.sort(reverse = True)
print(dc[k])

Submission status: Runtime Error

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

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

for k in da:
    if k in db:
    	dc.append(k)

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

Submission status: Runtime Error

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

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

for k in da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

Submission status: Runtime Error

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

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

for k in da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Submission status: Runtime Error

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

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

for k in range da:
    if k in db:
    	dc.append(k)

Submission status: Runtime Error

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

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

for k in range da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Submission status: Runtime Error

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

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

for k in range da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

else:
    print(0)

Submission status: Runtime Error

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

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

for k in range da:
    if k in db:
    	dc.append(k)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
import math
n = math.gcd(a,b)
divisor = []
for i in range(n/2+1):
  if n % (i+1) == 0:
    divisor.append(i+1)
print(divisor[-k])

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
mx = round(max(a, b) * 0.5)
match, ans = 0, 0

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

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
mx = max(a, b) * 0.5
match, ans = 0, 0

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

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
mx = max(a, b) * 0.5
match, ans = 0, 0

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

Submission status: Runtime Error

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

print(numlst[k-1])

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
mx = max(a, b) * 0.5
match, ans = 0, 0

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

Submission status: Runtime Error

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

g = math.gcd(a, b)
l=[]
for i in range(1,g+1):
  if g % i == 0:
    l.append(i)
print(l[-k])

Submission status: Runtime Error

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

g = math.gcd(a, b)
l=[]
for i in range(1,g+1):
  if g % i == 0:
    l.append(i)
print(i[-k])

Submission status: Runtime Error

Solution code:
# B - K-th Common Divisor
# https://atcoder.jp/contests/abc120/tasks/abc120_b
# 1WA
import math

MAX = 100

def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

prime_table = [True]*MAX
prime_table[0] = prime_table[1] = False
for i in range(2, int(math.sqrt(MAX)) + 1):
    for j in range(i*2, MAX, i):
        prime_table[j] = False
primes = [i_idx for i_idx in range(len(prime_table)) if prime_table[i_idx] == True]

A, B, K = map(int, raw_input().split())
gcdAB = gcd(A, B)

factors = set()
factors.add(gcdAB)
factors.add(1)

for prime in primes:
    if prime > gcdAB:
        break
    if gcdAB % prime == 0:
        factors.add(prime)
        factors.add(gcdAB/prime)

factors = list(factors)
factors.sort(reverse=True)

print '{}'.format(factors[K - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import factorial
a,b,k=map(int,input().split())
n=math.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[k-1])

Submission status: Runtime Error

Solution code:
# B - K-th Common Divisor
# https://atcoder.jp/contests/abc120/tasks/abc120_b
import math

MAX = 100

def gcd(A, B):
    if B > A:
        A, B = A, B

    if B == 0:
        return A

    return gcd(B, A-(A/B)*B)

prime_table = [True]*MAX
prime_table[0] = prime_table[1] = False
for i in range(2, int(math.sqrt(MAX)) + 1):
    for j in range(i*2, MAX, i):
        prime_table[j] = False
primes = [i_idx for i_idx in range(len(prime_table)) if prime_table[i_idx] == True]

A, B, K = map(int, raw_input().split())
gcdAB = gcd(A, B)
factors = set()
factors.add(gcdAB)
factors.add(1)

for prime in primes:
    if prime > gcdAB:
        break
    if gcdAB % prime == 0:
        factors.add(prime)
        factors.add(gcdAB/prime)

factors = list(factors)
factors.sort(reverse=True)

print '{}'.format(factors[K - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

List = [x for x in range(min(A,B),1,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

Submission status: Runtime Error

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

List = [x for x in range(max(A,B),1,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


def f(s, l, k):
    numbers = []
    for i in range(2, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if A == 1 or B == 1:
    print(1)
else:
    print(listAB[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


A = []

B = []


for i in range (1,a+1):

	if(a % i == 0):

		A.append(i)


for j in range (1,b+1):

	if(a % i == 0):

		B.append(j)


G = set(A) & set(B)


G.reverse()



print(G[k])

Submission status: Runtime Error

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


A = []

B = []


for i in range (1,a+1):

	if(a % i == 0):

		A.append(i)


for j in range (1,b+1):

	if(a % i == 0):

		B.append(j)


G = set(A) and set(B)


G.reverse()



print(G[k])

Submission status: Runtime Error

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

A = []
B = []

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

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

G = set(A) and set(B)

G.reverse()

num = input()

print(G[num])

Submission status: Runtime Error

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

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

print(l[k-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = [i for i in range(1, A+1) if A % i == 0]
b = [i for i in range(1, B+1) if B % i == 0]
ans = set(a) & set(b)
print(list(ans)[K])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, k = (int(i) for i in input().split())
cdiv = []
ans = []
a,b = min(a,b),max(a,b)
for i in range(1, a + 1):
    if a % i == 0:
        cdiv.append(i)
for i in cdiv:
    if b % i != 0:
        ans.append(i)


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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    A,B,C = map(int, input().split())
    if A>B:
        D=A
    else:
        D=B

    list =[]
    for i in range(D):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# 与えられた整数の約数を返す
def func_divisors(x):
  divisors = []
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      divisors.append(i)
      if i != x / i:
        divisors.append(int(x/i))
        
  divisors.sort()
  return divisors
  
A_divisors = func_divisors(A)
B_divisors = func_divisors(B)
C_divisors = list(set(A_divisors) & set(B_divisors))

print(C_divisors[K-1])

Submission status: Runtime Error

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

res_a = set() 
res_b = set() 
lim = min(A, B)
for i in range(1, lim):
    if A%i == 0:
        res_a.add(i)
    if B%i == 0:
        res_b.add(i)

a_b_union = list(res_a | res_b)

print(a_b_union[K-1])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
n = 0
for i in range(min(a,b)):
  if a%i == 0 and b%i == 0:
    n += 1
    if n ==c:
      print(i)
      break
    else:
      pass

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
n = 0
for i in range(min(a,b)):
  if a%i = 0 and b%i =0:
    n += 1
    if n ==c:
      print(i)
      break
    else:
      pass

Submission status: Runtime Error

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

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0 and m % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")

Submission status: Runtime Error

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

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0:
        ans.append(i)

#print(ans)
if ans:
    print(ans[k-1])
else:
    print("1")

Submission status: Runtime Error

Solution code:
import math
a,b,k = list(map(int,input().split()))
c = math.gcd(a,b)
d = list()
e = 0
for i in range(1,(c//2)+1):
    if c%i == 0:
        e +=1
        if e == k:
            print(int(c/i))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a, b, k =map(int, input().split())
divesor_list = []
if min(a, b) == 1:
    divesor_list = [1]
else:
    for i in range(min(a, b), 0, -1):
            if gcd % i == 0:
                divesor_list.append(i)
print(divesor_list[k-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,min(A,B)):
    if A%i==0 and B%i==0:
        result.append(i)
result.reverse()
print(result[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,max(A,B)):
  if A%i==0 and B%i==0:
    result.append(i)
print(result[K-1])

Submission status: Runtime Error

Solution code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,max(A,B)):
    if A%i==0 and B%i==0:
        result.append(i)
print(result[K-1])

Submission status: Runtime Error

Solution code:
from sys import stdin
import math

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

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

print(num_list[-(K)])

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
a,b,k= map(int,input().split())
c = []
for i in range(1, int(a**0.5)+1):
    if a % i == 0:
      c.append(i)
      if i != a // i:
          c.append(a//i)
d = []
for j in range(1, int(b**0.5)+1):
    if b % j == 0:
      d.append(i)
      if j != b // j:
          d.append(b//j)
l= sorted(set(c) & set(d))
print(l[k-1])

Submission status: Runtime Error

Solution code:
import numpy as np

def divs(_n):
    n = _n
    r = int(np.sqrt(n))
    res = []
    
    for i in range(2, r+1, 1):
        buf = [0, 0]
        while n%i == 0:
            buf[0] = i
            buf[1] += 1
            n/=i
        if buf[0] != 0:
            res.append(buf)
    if len(res)==0:
        res.append([n, 1])
        
    return res


def has(lis, num, search_i):
    beki = -1
    index = -1
    for i in range(search_i, len(lis), 1):
        #print(type(i))
        if lis[i][0] == num:
            beki = lis[i][1]
            index = i
            break
    return (beki, index)


def common_divs(_a, _b):
    # len(a) <= len(b)
    if len(_a) > len(_b):
        a = _b
        b = _a
    else:
        a = _a
        b = _b

    common = []
    search_i = 0 # from this index, search e[0] in list b
    for e in a:
        beki, index = has(b, e[0], search_i)
        if beki > 0:
            common_e = [e[0], min(e[1], beki)]
            common.append(common_e)
            search_i = index + 1
    return common

def mult_all(c):
    res = 1
    for i in range(len(c)):
        res *= c[i][0]**c[i][1]
    return res


def main():
    a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)
    divC = common_divs(divA, divB)
    
    #print ( divA, '\n', divB, '\n', divC, '\n')
    cnt = 1
    i = 0
    ans = mult_all(divC) 
    while(True):
        if cnt + divC[i][1] <= k:
            ans /= divC[i][0]**divC[i][1]
            cnt += divC[i][1]
        else:
            ans /= divC[i][0]**(k-cnt)
            break
        i += 1
        
    print(int(ans))

main()

Submission status: Runtime Error

Solution code:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
print(yakusuu_arr)
print(yakusuu_arr[-K+1])

Submission status: Runtime Error

Solution code:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
print(yakusuu_arr[K-1])

Submission status: Runtime Error

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
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
print(yakusuu_arr[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

i=0
j=1
while i<K:
  if A%j=0 and B%j=0:
     i +=1
  else:
     i =i
  j+=1

print(j)

Submission status: Runtime Error

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

i=0
j=1
while i<K:
  if A%j=0^B%j=0:
     i +=1
  else:
     i =i
  j+=1

print(j)

Submission status: Runtime Error

Solution code:
import math
n,m,k=map(int,input().split())
print(math.gcd(n,m))

Submission status: Runtime Error

Solution code:
import math
n,m,k=map(int,input().split())
g=math.gcd(n,m)
for i in range(1,101):
	if g%i==0:
		k-=1
		if k==0:
			print(i)
			exit()

Submission status: Runtime Error

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

risuto = []
for i in range(1, int(min(A, B) / 2) + 1):
    if (A % i == 0 & B % i == 0):
        risuto.append(i)
        
if (risuto == []):
    print("1")
else:
    print(risuto[K-1])

Submission status: Runtime Error

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

if A > B:
	tmp = B
	B = A
	A = tmp

count = 0
ans = 0

for i in range(1,A+1):
	if A % i == 1 and B & i ==1
		count += 1
		if count == K:
			ans = i
			break

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a,b,k=map(int,input().split(" "))
g=math.gcd(a,b)
if k==1:
    print(g)
else:
    cnt = 1
    for n in range(2,g+1):
        if g%n==0:
            cnt+=1
            if cnt==k:
                print(int(g/n))
                break

Submission status: Runtime Error

Solution code:
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = D.index(int(c))
    print(q+1)

Submission status: Runtime Error

Solution code:
if a % i == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break

Submission status: Runtime Error

Solution code:
A, B, K = map(int, input().split())
max = 0
if A > B:
  max = A
else:
  max = B
divideCount = 0

for i in range(1, max):
  if A % i == 0 and B % i == 0:
    if divideCount == K:
      print(i)
      return
    else:
      divideCount += 1

Submission status: Runtime Error

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

for i in range(1, max):
  if A % i == 0 and B % i == 0:
    if divideCount == K:
      print(i)
      return
    else:
      divideCount += 1

Submission status: Runtime Error

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

for i in range(1, max):
  if A % i == 0 && B % i == 0:
    if divideCount == K:
      print(i)
      return
    else:
      divideCount += 1

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

max = max(a, b)
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])