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: Wrong Answer

Solution code:
from fractions import Fraction

data = input().split()
a = int(data[0])
b = int(data[1])
k = int(data[2])

def fuc(left, right):
    val = Fraction(left, right)
    ans = val.denominator
    while ans%2 ==0:
        ans=ans//2
    while ans%5 ==0:
        ans=ans//5
    return ans==1

ans = []
i=0
while True:
    i+=1
    if fuc(a, i) and fuc(b, i) == 0:
        ans.append(i)
    if len(ans) > k:
        break

print(ans[k-1])

Submission status: Wrong Answer

Solution code:
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for h in range(51):
	i= (b if a>b else a)-h
	if a%i + b%i:
		continue
	x=x+1
	if x == k:
		break
print(i)

Submission status: Wrong Answer

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


from sys import stdin


############################################

import numpy as np
# read data for n sequences.
n = stdin.readline().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])

ans = []
for i in range(1, a):
    if a%i==0:
        ans.append(i)
ans=sorted(ans,reverse=True)
if a == 1:
    ans=[1]
count=0

for i in ans:
    if b%i==0:
        count+=1
    if count==c:
        break
print(i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for h in range(51):
	i= (b if a>b else a)-h
	if a%i + b%i:
		continue
	x=x+1
	print(i)
	if x == k:
		break
print(i)

Submission status: Wrong Answer

Solution code:
A,B,K = [int(_) for _ in input().split()]
c = 0
i = 100
while True:
    if A%i == B%i == 0:
        c += 1
        print(i)
    if c == K:
        break
    i -= 1
print(i)

Submission status: Wrong Answer

Solution code:
import math
A,B,C=map(int,input().split())
res=0
for i in range(99):
  if A>=100-i or B>=100-i:
    if A%(100-i)==0 and B%(100-i)==0:
      res+=1
      if res==C:
        print(100-i)

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
count = int(0)
i = int(0)
l = list()

for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            count += 1
            l.append(i)
n = int(len(l))
n -= c
print(l[n])

Submission status: Wrong Answer

Solution code:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k * 1000000000
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m * 100000000000
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[inp[2]-1])

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while len(l)<k:
    if (a%i==0 and b%i==0) or i==2 or i==4 or i==8 or i == 16 or i == 32 or i == 64 or i == 5 or i == 25:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def isinteger(x):
	if isinstance(x, float):
		return x == int(x)
	else:
		return 1000000

game = [int(i) for i in input().split()]
A = game[0]
B = game[1]
K = game[2]

if A<B:
  x = B-A
  A = B
  B = A-x
i = 1
count = 0
while(i<100):
  t_1 = A/i
  t_2 = B/i
  t_1 = isinteger(t_1)
  t_2 = isinteger(t_2)
  
  if t_1 and t_2 < 100000 :
    count = count+1
    if count == K:
      print(i)
      break
  i = i+1

Submission status: Wrong Answer

Solution code:
import math
A,B,C=map(int,input().split())
res=0
for i in range(99):
  if A%(100-i)==0 and B%(100-i)==0:
      res+=1
      if res==C:
        print(100-i)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
a, b, k = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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:
        print(i)
        l.append(i)
print(l[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list=[]
list= [i for i in range(1,10000) if A%i==0 and B%i==0]
list[K-1]

Submission status: Wrong Answer

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

result = [k for k in range(1,B + 1) if A % k == 0 and B % k == 0]
result.sort()
print(result[K - 1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
list = []
list1 = []
for i in range(a):
  d = a % (i+1)
  if d == 0:
    list.append(i+1)
  else:
    pass
#print(list)
for k in range(len(list)):
  e = b % list[k]
  if e == 0:
    list1.append(list[k])
  else:
    pass
#print(list1)
if len(list1) >= c:
    print(list1[c-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while len(l)<k:
    if (a%i==0 and b%i==0) or i%2==0 or i%5==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Submission status: Wrong Answer

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

for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            count += 1
            if count == c:
                break

print(i)

Submission status: Wrong Answer

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

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

answer = List[k-1]

print(answer)

Submission status: Wrong Answer

Solution code:
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in reversed(range(min)):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(i)
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k * 1000
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m * 1000
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[inp[2]-1])

Submission status: Wrong Answer

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

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

GCA = gcd(A, B)
A_all_div=[]
B_all_div=[]


for i in range(1,A+1):
    if A % i == 0:
        if i <= GCA:
            A_all_div.append(i)
A_all_div.sort(reverse=True)

for i in range(1,B+1):
    if B % i == 0:
        if i <= GCA:
            B_all_div.append(i)
B_all_div.sort(reverse=True)

ALL_DIV = set(A_all_div) & set(B_all_div)
all_div = list(ALL_DIV)

print(all_div[K-1])

Submission status: Wrong Answer

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

print(cd[k-1])

Submission status: Wrong Answer

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

if (a == 0) or (b == 0):
    i = 0
elif a == b:
    print(a)
else:
    for i in range(1,100):
            if ((a % i) == 0) and ((b % i) == 0):
                count += 1
                if count == c:
                   break

print(i)

Submission status: Wrong Answer

Solution code:

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

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

def cd(a,k):
    for i in range(1,a+1):
        if a%i == 0:
            k = k-1
            if k==0:
                return i
    return -1

print(cd(gcd(a,b),k))

Submission status: Wrong Answer

Solution code:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k * 1000
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m * 1000
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li,li2,li3)
print(li3[inp[2]-1])

Submission status: Wrong Answer

Solution code:
a, b, k = map(int,input().split())
z = 1
A = 0
while (A != k):
    if a % z == 0 and b % z == 0:
        A += 1
    z += 1
print (z-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(List[k-1])

Submission status: Wrong Answer

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

if (a == 0) or (b == 0):
    i = 0
else:
    if a > b:
        flag = 1
    for i in range(1,100):
            if ((a % i) == 0) and ((b % i) == 0):
                count += 1
                if count == c:
                   break

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()

print(list3[max -1])

Submission status: Wrong Answer

Solution code:
import fractions
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass #sortされていない
a,b,k = map(int,input().split())
gcd = fractions.gcd(a,b)
yaku = list(reversed(sorted(divisor(gcd))))
print(yaku[k-1])

Submission status: Wrong Answer

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

list=[]
for j in range(1,99):
	a,b = A,B
	if a%j==0 and b%j==0:
		a,b = a/j, b/j
		list.append(j)

print(list[-K])

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
i = 1
j = 2
ans = 1
while (i < K):
    if (A % j == 0) & (B % j == 0):
        ans = j
        i += 1
    j += 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
#N = int(input())
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)
        #if len(ans) == K:
            #print(ans,K)
#print(ans)
print(ans[K-1])

Submission status: Wrong Answer

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

hoge = []
m = min(A, B)

for i in range(1, m + 1):
    if A % i == 0 and A / i > 0 and B % i == 0 and B / i > 0:
        hoge.append(i)
        
fuga = list(set(hoge))
a = len(fuga) - K
print(fuga[a])

Submission status: Wrong Answer

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

    num = []

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

    print(num[-k])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for i in range(1,51):
	if a%i + b%i:
		continue
	x+=1
	if x == k:
		break
print(i)

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
i = 1
j = 1
ans = 1
while (i < K):
    if (A % j == 0) & (B % j == 0):
        ans = j
        i += 1
    j += 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()
print(list3[max -1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (a == 0) or (b == 0):
    i = 0
else:
    for i in range(1,100):
            if ((a % i) == 0) and ((b % i) == 0):
                count += 1
                if count >= c:
                   break

print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
m = max(a,b)
al = [i for i in range(1,m+1) if a%i==0]
bl = [i for i in range(1,m+1) if b%i==0]
ans = list(set(al)&set(bl))[::-1]
print(ans[k-1])

Submission status: Wrong Answer

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

A_list=list()
B_list=list()
C_list=list()

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

for x in range(B+1):
    if x==0:
        continue
    if B%x==0:
        B_list.append(x)

for y in A_list:
    for z in B_list:
        if y==z:
            C_list.append(y)


print(C_list[K-1])

Submission status: Wrong Answer

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

hoge = []
m = min(A, B)

for i in range(1, m + 1):
    if A % i == 0 and A // i > 0 and B % i == 0 and B // i > 0:
        hoge.append(i)
        
fuga = list(set(hoge))
a = len(fuga) - K
print(fuga[a])

Submission status: Wrong Answer

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

rtn = 1;
rtn_list =[] 
while len(rtn_list) < K:
    if not(A % rtn) and not(B % rtn):
        rtn_list.append(rtn)
    rtn += 1
print(rtn_list[-1])

Submission status: Wrong Answer

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

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

print(List[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()
print(list3)
print(list3[max -1])

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split(' '))
A_set = set()
B_set = set()
for number in range(1, A+1):
    if A%number == 0:
        A_set.add(number)

for number in range(1, B+1):
    if B%number == 0:
        B_set.add(number)

A_Bset = A_set & B_set
A_Blist = list(A_Bset)
A_Blist.sort()
print(A_Blist[K-1])

Submission status: Wrong Answer

Solution code:
"""
    正解数　A,B
    正の整数　Z：A,Bも割り切る
    出力：Zの内K番目に大きいもの
"""

a, b, k = map(int, input().split())
i = 1
z = []

while i < 100:
    if (a % i == 0 and b % i == 0):
        z.append(i)
    i += 1
    
print(z[-k])

Submission status: Wrong Answer

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

yakusuu=[]
yakusuuA = []
yakusuuB = []
for i in range(1,A+1):
  if A% i == 0:
    yakusuuA.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuuB.append(j)
    
yakusuu = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu)[K-1])

Submission status: Wrong Answer

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)
print(ans[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
for i in range(1,10**5):
    if len(str(A/i)) < 14 and len(str(B%i)) < 14:
        counta += 1
    if counta == K:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

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

arr1 = [i for i in range(1,A + 1) if A % i == 0]
arr2 = [j for j in range(1,B + 1) if B % j == 0]

result = list(set(arr1) & set(arr2))
result.sort()
print(result[K - 1])

Submission status: Wrong Answer

Solution code:
import queue
a,b,c = map(int,input().split())
q = queue.LifoQueue()
for i in range(1,100):
  if(a%i == 0 and b%i == 0):
    q.put(i)
for i in range(c-1):
  q.get()
print(q.get())

Submission status: Wrong Answer

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

yakusuu=[]
yakusuuA = []
yakusuuB = []
for i in range(1,A+1):
  if A% i == 0:
    yakusuuA.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuuB.append(j)
    
yakusuu = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu)[K])

Submission status: Wrong Answer

Solution code:
a,b,c = (int(i) for i in input().split())  
result=[1]
count=2
while(not count>=max([a,b])):
    if(a%count==0 and b%count==0):
        result.append(count)
    count+=1
print(result[len(result)-c])

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
i = 0
j = 1
while (i < K):
    if (A % j == 0) & (B % j == 0):
        ans = j
        i += 1
    j += 1

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def euclidean(a,b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    if a%b != 0:
        return euclidean(a%b, b)
    else:
        return b

n = euclidean(a, b)
print(n)
for i in range(n , 0, -1):
  #print(i)
  if a % i == 0 and b % i == 0:
    k -= 1
    if k ==0:
      print(i)
      exit()

Submission status: Wrong Answer

Solution code:
a,b,k=list(map(int,input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
num=gcd(a,b)
print("gcd",num)
c=[]
for i in range(1,num+1):
    if num % i == 0:
        c.append(i)

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

Submission status: Wrong Answer

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

e = []
for i in range(1,b+1):
    if b%i == 0:
        e.append(i)

f = set(d) & set(e)
f = list(f)
f = f[::-1]
print(f[c-1])

Submission status: Wrong Answer

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

hoge = []
m = max(A, B)

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

Submission status: Wrong Answer

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

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


GCA = gcd(A, B)
all_div=[]

C = min(A,B)

for i in range(1,C+1):
    if C % i == 0:
        if i <= GCA:
            all_div.append(i)
all_div.sort(reverse=True)
print(all_div[K-1])

Submission status: Wrong Answer

Solution code:
import fractions

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

n = fractions.gcd(a, b)

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

print(l[k - 1])

Submission status: Wrong Answer

Solution code:
#import math

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


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

Max = int(gcd(A, B) )


list = [0] * 100

j =0

if A == 1 or B == 1:
    print("1")
    quit()

for i in range(Max):

    if i == 0:
        continue
    if Max % i == 0:
        list[j] = i
        j += 1


print(list[j - K+1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


GCA = gcd(A, B)
all_div=[]

C = min(A,B)

for i in range(1,C+1):
    if C % i == 0:
        if i <= GCA:
            all_div.append(i)
all_div.sort(reverse=True)
print(all_div[K-1])

Submission status: Wrong Answer

Solution code:
import sys

data= sys.stdin.readline().split(" ")
a = int(data[0])
b = int(data[1])
k = int(data[2])

if a == 1 or b == 1:
    print(a)

else:
    t = a
    if a < b:
        t = b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c = map(int, input().split())
def m(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


list = m(a)+ m(b)
res = [e for e in set(list) if list.count(e) > 1]
print(res)
print(res[c-1])

Submission status: Wrong Answer

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

print(i)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
A, B, K = map(int, input().split())
count = 1
def isFinite(num, den):
    fra = Fraction(num, den)
    den = fra.denominator
    while den % 2 == 0:
        den //= 2
    while den%5 == 0:
        den //= 5
    return den == 1

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

Submission status: Wrong Answer

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

array1 = []
array2 = []

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

array = list(set(array1) & set(array2))
print(array[-k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
n = 1
count = 0
list = []
while count < k:
    if a % n == 0 and b % n == 0:
        list.append(n)
        count += 1
        n += 1
    else:
        n += 1
print(list[k-1])

Submission status: Wrong Answer

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

#a_list.extend(b_list)
#co_divisor = list(set(a_list))
a_list = set(a_list)
b_list = set(b_list)
co_divisor = list(a_list & b_list)
co_divisor.sort()
print(co_divisor[k-1])

Submission status: Wrong Answer

Solution code:
import sys


def main():
    lines = sys.stdin.readlines()[0].split(' ')
    a = int(lines[0])
    b = int(lines[1])
    k = int(lines[2])
    count = 0

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(i)

Submission status: Wrong Answer

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

#a_list.extend(b_list)
#co_divisor = list(set(a_list))
a_list = set(a_list)
b_list = set(b_list)
co_divisor = list(a_list & b_list)
co_divisor.sort()
print(co_divisor)
print(co_divisor[k-1])

Submission status: Wrong Answer

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

hoge = []
m = min(A, B)

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

Submission status: Wrong Answer

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

yakusuu=[]
for i in range(1,A+1):
  if A% i == 0:
    yakusuu.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuu.append(j)
   
yakusuu.append(1)  
    
print(sorted(yakusuu)[K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(lst[-k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
i=1
li=[1]
while i<min([A,B]):
  i=i+1
  if A%i == B%i == 0:
    li.append(i)
print(li[K-1])

Submission status: Wrong Answer

Solution code:
a, b, k = [int(x) for x in input().split()]
al = set()
bl = set()
for i in range(1, a+1):
    if a%i == 0:
        al.add(i)
for i in range(1, b+1):
    if b%i == 0:
        bl.add(i)
kk = list(al | bl)
kk.sort()
print(kk[k-1])

Submission status: Wrong Answer

Solution code:

# coding: utf-8

# In[26]:


import sys


# In[91]:


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


# In[92]:


def yakusuu(x):
    yakusuu_array = []

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


# In[93]:


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


# In[94]:


if K > 1:
    print(y_list[K-1])
else:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(j)

Submission status: Wrong Answer

Solution code:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[inp[2]-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c = (int(i) for i in input().split())  
result=[1]
count=2
while(not (len(result) is c)):
    if(a%count==0 and b%count==0):
        result.append(count)
    count+=1
print(result[c-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

yakusuu=[]
for i in range(1,A+1):
  if A% i == 0:
    yakusuu.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuu.append(j)
    
print(sorted(yakusuu)[K])

Submission status: Wrong Answer

Solution code:
import sys

data= sys.stdin.readline().split(" ")
a = int(data[0])
b = int(data[1])
k = int(data[2])

if a == 1 or b == 1:
    print(a)

else:
    t = a
    if a < b:
        t = b

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

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
k = 0
x = 1
l = [0]
for x in range(min([A, B])+1):
    if x != 0:
        if A % x == 0 & B % x == 0:
            l.append(x)


print(l[K])