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

div_a = [d for d in range(1, a+1) if a % d == 0]
div_b = [d for d in range(1, b+1) if b % d == 0]
div_a.extend(div_b)
print(list(set(div_a))[k-1])

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split(" "))
flag = True
counter = 0
i = 1
while True:
  if A % i == 0 and B % i == 0:
    counter += 1
    if counter == K:
      print(i)
      break
  i += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


ans.sort()
print(ans[k-1])

Submission status: Wrong Answer

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

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

print(e[k-1])

Submission status: Wrong Answer

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

if len(mods) == 1:
    print(mods[0])
else:
    print(mods[k-1])

Submission status: Wrong Answer

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

k = 0
for i in range(1,max(A,B))[::-1]:
    if A%i ==0 and B%i ==0:
        k += 1
        if k ==K:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
A,B,K = input().split(' ')
A = int(A)
B = int(B)
K = int(K)
count = 0
for i in range(1,101):
    if A%i == 0 and B%i ==0:
        count += 1
        if count == K:
            print(i)
            exit()

Submission status: Wrong Answer

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

count = 1
for i in xrange(100):
    if i == 0: continue
    if A % i == 0 or B % i == 0:
        if count == K:
            print str(i)
            break
        count += 1

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

d = gcd(A, B)

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

ass = list(set(divisor(d)))
#print(ass)
out = ass[-K]
print(out)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

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

a, b, k = list(map(int, stdin.readline().rstrip().split()))
g = gcd(a,b)

cnt = 0
for i in range(g+1 // 2):
	if g % (i+1) == 0:
		cnt += 1
	if cnt == k:
		print(i+1)
		sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

nums = []

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

if nums == []:
    print(1)
else:
    print(nums[K-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

divisor = set(divisorA + divisorB)

divisor = sorted(divisor &  set(divisorA) )

print( divisor[k-1] )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,b+1):
    if b % i == 0:
        l2.append(i)
s1 = set(l1)
s2 = set(l2)
ans = s1 & s2
ans_list = list(ans)
print(ans_list[-k])

Submission status: Wrong Answer

Solution code:
#import sys
#input = sys.stdin.readline
import random
import bisect
#from statistics import mean, median, variance, stdev

#template input

def IT(): #整数1個
    return int(input())
def IL(): #整数複数
    return [int(_) for _ in input().split()]
def IS(): #文字列複数
    return [_ for _ in input().split()]
def ILS(n): #整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]
def SLS(n): #文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]
def ILSS(n): #整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)
def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x:x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val
def matching_bisect(list1_val, list2_val, n):
    #2分探索
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                #ans = list2_bin[j] + list1_bin[i]
                break
    return j

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

def main():

    a,b,k = IL()
    c = 0
    for i in range(101, 1, -1):
        if (a)%i == 0 and (b)%i == 0:
            #print(i)
            c += 1
            if c == k:
                print(i)
                break








main()

Submission status: Wrong Answer

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

aa =[]
bb=[]
cc=[]

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

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

cc=sorted(list(set(aa) & set(bb)))
print(cc[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = []
for i in range(1, a+1 if a < b else b+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)
    elif i%3 != 0 and i%7 != 0:
        ans.append(i)

print(ans[k-1])

Submission status: Wrong Answer

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

for x in range(1, 100):
    if a%x==0 and b%x==0:
        lst_ans.append(x)
lst_ans = sorted(lst_ans, reverse=True)
print(lst_ans[(k-1)])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp = []
if A > B:
    for i in range(A):
        if A % (i+1) == 0 & B % (i+1) == 0:
            tmp.append(i+1)
else:
    for i in range(B):
        if A % (i+1) == 0 & B % (i+1) == 0:
            tmp.append(i+1)

print(str(tmp[K-1]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def _main():
    text = input()
    A, B, K = [int(i) for i in text.split(' ')]

    count = 0
    num = 1

    while True:
        if A%num == 0 and B%num == 0:
            count += 1

            if count == K:
                break

        num += 1

    print(num)

if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

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

count = 0
delim = 0

while count != K:
    delim += 1
    if A % delim == 0 and B % delim == 0:
        count += 1
    

print(delim)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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

print(commons[abk[2]-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

count = 0

if k == 1:
    print(1)

else:

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

        if count == k:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
#ABC120B-K-thCommonDivisor.py

from sys import stdin

input = stdin.readline

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

commonDivisor = []

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

Submission status: Wrong Answer

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

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:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Submission status: Wrong Answer

Solution code:
Aa,Bb,Cc=input().split()
A=int(Aa)
B=int(Bb)
C=int(Cc)
count=0
kazu=min(A,B)
S=[]
for i in range(1,kazu+1):
    if A%i==0 and B%i==0:
        S.append(i)
   
print(S[C-1])

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
def make_divisor_list(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_a = make_divisor_list(a) 
list_b = make_divisor_list(b)
a_b = set(list_a) & set(list_b)

print(list(a_b)[-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, raw_input().split())
for i in range(1, min(a,b) + 1):
    if a % i == 0 & b % i == 0:
        k -= 1
        if k == 0:
            print(i)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d = 1
i = 0
while True:
    if (A % d == 0) and (B % d == 0):
        i += 1

    if i == K:
        break

    d += 1
    

print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


count = 0
i = 1

while True:
    if len(str(a / i)) < 10 and len(str(b % i)) < 10:
        # print(i)
        count += 1
    if count == k:
        print(i)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
def main():
    a, b, k = list(map(int, input().split()))
    lst = []
    for i in range(1, 101):
        if a % i == 0 and b % i == 0:
            lst.append(i)
    return sorted(lst, reverse=True)[k-1]

main()

Submission status: Wrong Answer

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

d =list()
for i in range(1,100):
	if a%i == 0 and b%i ==0:
		d.append(i)
		if len(d) == c:
			print(c)
			break

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
a_lst=[]
b_lst=[]
for i in range(1,101):
    if a%i == 0:
        a_lst.append(i)
    if b%i == 0:
        b_lst.append(i)
a_lst.extend(b_lst)
a_lst=sorted(a_lst)
count=0
for i in range(len(a_lst)-1):
    if a_lst[i] == a_lst[i-1]:
        count+=1
        if count == c:
            print(a_lst[i])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())

A, B, K = tuple(li())
count = 0
for num in range(1, A + 1):
    if A % num == 0 and B % num == 0:
        count += 1
        if count == K:
            print(num)
            break

Submission status: Wrong Answer

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

i = 1
j = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
[a,b,k] = [int(i) for i in input().split()]
counter = 0
c = fractions.gcd(a,b)
for i in range(c+1,1,-1):
    if c % i == 0:
        counter += 1
        #print(i)
    if counter == k:
        print(i)
        break

Submission status: Wrong Answer

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

for x in range(1, 100):
    if a%x==0 and b%x==0:
        lst_ans.append(x)
print(lst_ans[(-k)])

Submission status: Wrong Answer

Solution code:

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

count = 0

if k == 1:
    print(1)

else:

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

        if count == k:
            print(i)
            break

Submission status: Wrong Answer

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

print(k)

Submission status: Wrong Answer

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

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

print(res[-k])

Submission status: Wrong Answer

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

cnt = 0

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

Submission status: Wrong Answer

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

i = 1
count = 0

while True:

    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)
            break

    i += 1

Submission status: Wrong Answer

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

r=[]

for i in range(100):
  if(a%(i+1)==0 and b%(i+1)==0):
    r.append(i+1)
    
print(r[k-1])

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
ans = 1
i = 1
found = False
while ans <= a and ans <= b and not found:
    if a % ans == 0 and b % ans == 0:
        print(ans)
        if i == k:
            found = True
            print(ans)
        i += 1
    ans += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
A_box = []
B_box = []
for i in range (1,101):
    if (A/i) == int(A/i):
        A_box.append(i)
    if (B/i) == int(B/i):
        B_box.append(i)
result=set(A_box) & set(B_box)
print(list(result)[-K])

Submission status: Wrong Answer

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

for x in range(1, 100):
    if a%x==0 and b%x==0:
        lst_ans.append(x)
print(lst_ans)
print(lst_ans[(-k)])

Submission status: Wrong Answer

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

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

        if count == K:
            answer = i
            break

print(answer)

Submission status: Wrong Answer

Solution code:
A, B, K =map(int, input().split())
A_yaku = []
for i in range(1, int(A/2)+1):
    if A % i == 0:
        A_yaku.append(i)
A_yaku.append(A)
B_yaku = []
for i in range(1, int(B/2)+1):
    if B % i == 0:
        B_yaku.append(i)
B_yaku.append(B)
A_yaku = set(A_yaku)
B_yaku = set(B_yaku)

co_yaku = list(A_yaku & B_yaku)

for i in range(K):
    tmp = co_yaku.pop(-1)
print(tmp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d =list()
for i in range(1,a):
	if a%i == 0 and b%i ==0:
		d.append(i)
		if len(d) == c:
			print(c)
			break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
lis = []
for i in range(1, 100):
    if A % i == 0 and B % i == 0:
        lis.append(i)
    else:
        pass

print(lis[-(K)])

Submission status: Wrong Answer

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

i = 1
count = 0

while True:

    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(K)
            break

    i += 1

Submission status: Wrong Answer

Solution code:
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

A,B,K = IL()

cnt = 0
i = 1
while True:
    if A%i==0 and B%i==0:
        cnt += 1
    if cnt == K:
        print(i)
        break
    i += 1

Submission status: Wrong Answer

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)
print(list[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
num = 1
count = 0
while True:
  if a%num==0 & b%num==0:
    count += 1
  if count==k:
    print(num)
    exit()
  num+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a == 1 or b == 1:
    print(1)
    sys.exit(0)

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

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

Submission status: Wrong Answer

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys

a,b,k = map(int, sys.stdin.readline().rstrip().split())

ans = []

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

print(ans[k-1])

Submission status: Wrong Answer

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

a = set()
b = set()

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

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

c = list(a & b)
c.reverse()

print(c[K-1])

Submission status: Wrong Answer

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

tmp = 0

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

Submission status: Wrong Answer

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

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

print(num_list[k-1])

Submission status: Wrong Answer

Solution code:
#import sys
#input = sys.stdin.readline
import random
import bisect
#from statistics import mean, median, variance, stdev

#template input

def IT(): #整数1個
    return int(input())
def IL(): #整数複数
    return [int(_) for _ in input().split()]
def IS(): #文字列複数
    return [_ for _ in input().split()]
def ILS(n): #整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]
def SLS(n): #文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]
def ILSS(n): #整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)
def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x:x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val
def matching_bisect(list1_val, list2_val, n):
    #2分探索
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                #ans = list2_bin[j] + list1_bin[i]
                break
    return j

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

def main():

    a,b,k = IL()
    c = 0
    for i in range(1, 101):
        if (10000000000000*a)%i == 0 and (10000000000000*b)%i == 0:
            #print(i)
            c += 1
            if c == k:
                print(i)
                break








main()

Submission status: Wrong Answer

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

count = 0
n = 1
while(k != count):
    if (a % n == 0 and b % n == 0):
        count += 1
    n += 1

print(n - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split(" "))
flag = True
counter = 0
i = 1
while True:
  if A % i == 0 and B % i == 0:
    counter += 1
    print(i)
    if counter == K:
      print(i)
      break
  i += 1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
A, B, K = map(int, input().split())

num = 0
for i in range(1, B + 1):
    if (A % i == 0 and B % i == 0):
        num += 1
    if (num == K):
        break

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

input = sys.stdin.readline

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

A, B, K = [int(x) for x in input().split()]
c = 0
for i in range(1, 100):
    if A % i == 0 and B % i == 0:
        c += 1
        debug(A, B, i, "c=",c)
        if c == K:
            print(i)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m = max(a,b)
c = 0;

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while i < k:
    if a % curr == 0 and b % curr == 0:
        i += 1
    curr += 1

print(curr-1)

Submission status: Wrong Answer

Solution code:
import sys

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

i = 1
count = 0

while True:

    if A % i == 0 and B % i ==0:
        count += 1
        if count == K:
            print(K)
            sys.exit()

    i += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans[-k])

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b,c = LI()
print(min(b//a,c))
"""

#B
a,b,k = LI()
i = 1
d = 1
while d < k:
    i += 1
    if a%i == 0 and b%i == 0:d += 1
print(i)
#C
"""
s = S()
n = len(s)
while len(s)>1:
    i = 0
    f = True
    while s[i] == s[i+1]:
        if i+1 == len(s)-1:
            f = False
            break
        i += 1
    if not f:break
    s.pop(i)
    s.pop(i)
print(n-len(s))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import fractions

a,b,k=map(int,input().split())
c=fractions.gcd(a,b)
l=[c]
for i in range(1,c):
  if a%i==0 and b%i==0:
    l.append(i)
l.sort()
print(l)
print(l[-k])

Submission status: Wrong Answer

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

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div

g = gcd(A, B)
v = divisors(g)
print(v[K-1])