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:
memo = []

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

Submission status: Wrong Answer

Solution code:
a,b,k=map(int,input().split())
s=set()
x=1
while(x*x<=a):
  if(a%x==0):
    s.add(x)
  if(a//x!=x and a%(a//x)==0):
    s.add(a//x)
  x+=1
x=1
while(x*x<=b):
  if(b%x==0):
    s.add(x)
  if(b//x!=x and b%(b//x)==0):
    s.add(b//x)
  x+=1
s=list(sorted(s))
count=0
for i in range(len(s)):
    if(a%s[i]==0 and b%s[i]==0):
        count+=1
    if(count==k):
        print(s[i])
        exit()

Submission status: Wrong Answer

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

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 (100000*a)%i == 0 and (100000*b)%i == 0:
            #print(i)
            c += 1
            if c == k:
                print(i)
                break








main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

divs = []

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

print(divs[k-1])

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
a,b,K=map(int,raw_input().split())

buf=[]
for k in range(1,100):
    if a%k==0 and b%k==0:
        buf.append(k)
print(list(reversed(buf))[K-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 & 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 = list(map(int, input().split()))
now = 0
for i in range(1, max(a[0], a[1])):
    if ((a[0] % i == 0) and (a[1] % i == 0)):
        now += 1
    if now == a[2]:
        print(i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

k=0
for i in range(max(A,B)+1,1,-1):
    #print(i)
    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 = map(int,input().split())
c = 1
while k!=0:
     if a%c==0 and b%c==0:
          k-=1
     c+=1
print(c-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,K = [int(_) for _ in input().split()]
M = A*B
print(M * K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

A,B,K = [int(x) for x in input().split()]

yakusu = defaultdict(int)

for a in range(A):
    a += 1
    if A % a == 0:
        yakusu[a] += 1
    if B >= a and B % a == 0:
        yakusu[a] += 1

nums = sorted([x for x in yakusu.keys() if yakusu[x] == 2])
print(nums[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
count = 0
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().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
      
check_list = []
check_list = make_divisor_list(a) + make_divisor_list(b)
print(list(set(check_list))[k-1])

Submission status: Wrong Answer

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

    count = 0

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding=utf-8


def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


if __name__ == '__main__':
    A, B, K = map(int, input().split())
    gcd = solve_gcd(A, B)
    ctr = 0
    for i in range(1, gcd+1):
        if gcd % i == 0:
            ctr += 1
        if ctr == K:
            print(ctr)
            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+1,1,-1):
  if (a%i==0) and (b%i==0):
    c += 1
  if c == k:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import fractions as f
a,b,k=map(int,input().split())
g=f.gcd(a,b)
count=0
#print(g)
for s in range(101,1,-1):
    if g%s==0:
#        print(s)
        count+=1
    if count==k:
        print(s)
        exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

cnt = 0

mini = min([a, b])
output = 1

for i in range(1, mini):
    if a % i == 0 and b % i == 0:
        cnt += 1
        output = i
    if cnt == k:
        break

print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

lst=input().split(" ")
A=int(lst[0])
B=int(lst[1])
K=int(lst[2])

count = 0

for i in range(1,max(A,B)+1):
    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())
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)
            exit()

Submission status: Wrong Answer

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

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


print(ans[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

li = []
s = 1
e = 0

while True:
    if a % s == 0 and b % s == 0:
        li.append(s)
        e += 1
    if e == k:
        break
    s += 1

print(li[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans =[]
dai = 0
if a>b:
    dai = a
else:
    dai = b
for i in range(1,dai+1):
    if a %i ==0 and b%i==0:
        ans.append(i)
ans.sort(reverse=True)
ans[k-1]

Submission status: Wrong Answer

Solution code:
# coding: utf-8
a, b, k = map(int, input().split())
cnt = 0
for i in range(1, min(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())
anskoho=[]
for i in range(1,100):
  if(a%i==0):
    if(b%i==0):
      anskoho.append(i)
      
#print(anskoho)
print(anskoho[-k])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def GCM(p, q):
  if p < q:
    t = p
    p = q
    q = t
  if p % q == 0:
    return q
  else:
    return GCM(q, p%q)
A, B, K = map(int, raw_input().split())
G = GCM(A, B)
i = 1
CM = []
while i*i <= G:
  if G % i == 0:
    CM.append(i)
    CM.append(G/i)
  i += 1
print sorted(CM)[-K]

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
cnt = 0
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:
#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 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())
s=set()
x=1
while(x*x<=a):
  if(a%x==0):
    s.add(x)
  if(a//x!=x and a%(a//x)==0):
    s.add(a//x)
  x+=1
x=1
while(x*x<=b):
  if(b%x==0):
    s.add(x)
  if(b//x!=x and b%(b//x)==0):
    s.add(b//x)
  x+=1
s=list(sorted(s))
print(s[k-1])

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(1,c+1):
    if c % i == 0:
        counter += 1
        #print(i)
    if counter == k:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

c = gcd(a, b)
cnt = 1
if k == 1:
    print(c)
    exit()
for i in range(2, c):
    if c % i == 0:
        cnt += 1
    if cnt == k:
        print(c // i)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(i)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc120/tasks/abc120_b

import itertools
import collections
import bisect

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
div = []
i = 1
while len(div) < K:
    if A % i == 0 & B % i == 0:
        div.append(i)
    i += 1
print(div[-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)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
A,B,K=[int(i) for i in 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)
        sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def main():
    a = list(map(int, input().split()))
    count = 0
    for i in range(1, a[0] + 1):
        if a[0] % i == 0 and a[1] % i == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

A,B,K = [int(x) for x in input().split()]

yakusu = defaultdict(int)

for a in range(A):
    a += 1
    if A % a == 0:
        yakusu[a] += 1
    if B % a == 0:
        yakusu[a] += 1

nums = sorted(yakusu.keys())
print(nums[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A, B, K = map(int, input().split())
cnt = 0
for i in range(1, 10**6):
    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())
cou = 0
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        cou += 1
    print(i,cou)
    if cou == k:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def main():
    a = list(map(int, input().split()))
    count = 0
    for i in range(1, a[0] + 1):
        if a[0] % i == 0 and a[1] % 1 == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

cnt = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b, k = map(int, input().split())
cnt = 0
for i in range(1, a*b*k+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 = (int(i) for i in input().split())
count = 0
res = 0
for i in range(1,101):
    if b%i == 0 and a%i == 0:
        count += 1
    if count == k:
        res = k
        break
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,k = [int(x) for x in input().split()]
num = 0
while 1:
  num += 1
  if (not a%num)and(not(b%num)):
    k -= 1
  if not k:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin
from math import sqrt

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

def gcd(A, B):
    if B > A:
        return gcd(B, A)
    while B != 0:
        A, B = B, A - B
    return A

def test_gcd():
    assert gcd(8, 4) == 4


A, B, K = tuple(li())
count = 0
g = gcd(A, B)
can = set()
cnt = 0
for i in range(1, int(sqrt(g)) + 1):
    if g % i == 0:
        cnt += 1
        can.add(i)
        can.add(g // i)
        if cnt >= K:
            break

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

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin
from math import sqrt

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

def gcd(A, B):
    if B > A:
        return gcd(B, A)
    while B != 0:
        A, B = B, A - B
    return A

def test_gcd():
    assert gcd(8, 4) == 4


A, B, K = tuple(li())
count = 0
g = gcd(A, B)
can = set()
for i in range(1, int(sqrt(g)) + 1):
    if g % i == 0:
        can.add(i)
        can.add(g // i)
can = sorted(can, reverse=True)
print(can[K - 1])

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin

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

def gcd(A, B):
    if B > A:
        return gcd(B, A)
    while B != 0:
        A, B = B, A - B
    return A

def test_gcd():
    assert gcd(8, 4) == 4


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

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in input().split()]
ans = []
if a > b:
    n = a
elif a < b:
    n = b
else:
    n = a

for x in range(1,n+1):
    if b % x == 0:
        if a % x == 0:
            ans.append(x)

print(ans[-k])

Submission status: Accepted

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

n = min(a,b)

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

Submission status: Accepted

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

count = 0
n = min(a, b)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
# aの約数
a_divisor = []
# abの公約数
ab_divisor = []

# aで割れたら順次約数に追加
for i in range(1,a+1):
    if a % i == 0:
        a_divisor.append(i)

# aの約数でbが割れたら公約数に追加
for j in a_divisor:
    if b % j == 0:
        ab_divisor.append(j)
# リストの大きい方からK番目の数値を出力
print(ab_divisor[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

print(i_list[len(i_list) - K])

Submission status: Accepted

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

Submission status: Accepted

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

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

print(cf(A,B)[-(K)])

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans[-k])