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:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = 0
    while t < K:
        i += 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()

Submission status: Wrong Answer

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

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

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
        print(i)
    if cnt == K:
        break
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ma = max(a, b)
mi = min(a, b)
ans = []
for i in range(ma // 2, 0, -1):
    if ma % i == 0 and mi % i == 0:
        ans.append(i)
ans.append(1)
print(ans[k - 1])

Submission status: Wrong Answer

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

    

main()

Submission status: Wrong Answer

Solution code:
import sys
import re
from decimal import *

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

minnum = min(l[0],l[1])
if(minnum == 1):
  print("1")
  exit(0)

no = l[2]
for i in range(minnum,1,-1):
  if(l[0] % i == 0 and l[1] % i == 0):
    no -= 1
    if(no == 0):
      print(i)


sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
import sys
import re
from decimal import *

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

minnum = min(l[0],l[1])

no = l[2]
for i in range(minnum,1,-1):
  if(l[0] % i == 0 and l[1] % i == 0):
    no -= 1
    if(no == 0):
      print(i)


sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
def make_divisors(a, b):
    divisors = set()
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            divisors.add(i)

    return divisors


a, b, k = map(int, input().split())
res = make_divisors(a, b)
res = list(res)
print(res[-k])

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

list_A = make_divisors(a)
list_B = make_divisors(b)

list_A = set(list_A)
list_B = set(list_B)

list_AB = list_A & list_B
list_AB = list(list_AB)
print(list_AB[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,a+1):
  if a%i==0 and b%i==0:
    li.append(i)
    
li.sort(reverse=True)

print(li[k-1])

Submission status: Wrong Answer

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


def main():
    a, b, k = map(int, input().split())
    ab_cf = cf(a, b)
    if len(ab_cf) == 1:
        ans = ab_cf[0]
    else:
        ans = sorted(ab_cf)[-2]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


a_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = [x for x in set(div_list) if div_list.count(x) > 1]

print(ans[-k])

Submission status: Wrong Answer

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

cnt = 1
waru = 1
while cnt < K:
    if A % waru == 0 and B % waru == 0:
        cnt += 1
        waru += 1
    else:
        waru += 1
if K == 1:
    print(1)
else:
    print(waru-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()
print(li)
print(li[-k])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,min(a,b)+1):
    if a%i==0:
        if b%i==0:
            ans.add(i)
ans=list(ans)
ans.sort()
print(ans[c-1])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,g+1):
    if g%i==0:
        ans.add(i)
        ans.add(g//i)
ans=list(ans)
ans.sort()
print(ans[c-1])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,s+1):
    if g%i==0:
        ans.add(i)
        ans.add(g//i)
ans=list(ans)
ans.sort()
print(ans[c-1])

Submission status: Wrong Answer

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

count = 0

l = []

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

Submission status: Wrong Answer

Solution code:
#ABC120

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(sorted(l,reverse = True)[k-1])

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 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())

i=1
idx = 0
while True:
  if a%i==0 and b%i==0:
    idx+=1
    
  if idx==k:
    break
  else:
    i+=1
    
print(i)

Submission status: Wrong Answer

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

aa = set([int(i) for i in range(1,a+1)])
ba = set([int(i) for i in range(1,b+1)])

print(list((aa & ba))[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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(0)

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
count = 0
for i in range(1,100):
    if round(a/i,10)==round(a/i,15) and round(b/i,10)==round(b/i,15):
        count += 1
        if count == k:
            print(i)
            exit(0)

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(0)

Submission status: Wrong Answer

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

print(ans[K-1])

Submission status: Wrong Answer

Solution code:
A,B,K=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[K-1])

Submission status: Wrong Answer

Solution code:
import fractions

A,B,K=map(int,input().split())
gcd=fractions.gcd(A,B)
#print(gcd)
l=[]
for i in range(1,gcd+1):
    if gcd%i==0:
        l.append(i)
print(l)
print(l[len(l)-K])

Submission status: Wrong Answer

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

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, k = map(int, 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)
            return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, k = map(int, input().split())
    count = 0
    for i in range(1, max(a, b)):
        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:
def main():
    a, b, k = map(int, input().split())
    count = 0
    for i in range(1, max(a, b)):
        if a % i == 0 and b % i == 0:
            print(i)
            count += 1
        if count == k:
            # print(i)
            return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,k=mii()
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)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,k=mii()
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)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,k=mii()

def mdiv(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors

aa=mdiv(a)
bb=mdiv(b)
ans=set(aa)&set(bb)
print(list(ans)[k-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:
a,b,k = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()　#小さい順位欲しいとき
    return divisors
Anoyatu=make_divisors(A)
Bnoyatu=make_divisors(B)
ans=list(set(Anoyatu)&set(Bnoyatu))
ans.sort()
#print(ans)
print(ans[K-1])

Submission status: Wrong Answer

Solution code:

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[k-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
class Solution:
    def solve(self, A: int, B: int, K: int) -> str:

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

            if count == K:
                return i


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(A, B, K))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    diviser = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            diviser.append(i)
    diviser.sort()
    print(diviser[K - 1])

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    diviser = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 or B % i == 0:
            diviser.append(i)
    diviser.sort()

    print(diviser[K - 1])

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S.sort(reverse=True)
print(S)
print(S[K-1])

Submission status: Wrong Answer

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

S.sort(reverse=True)
#print(S)
print(S[K-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:
A, B, K = map(int, input().split())

k = 0
for i in range(1, 100):
  if A%i == B%i == 0:
    k += 1
    if k == K:
      print(i)
      quit()

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
N=100
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
r.sort(reverse=True)
print(r[K-1])

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
N=100
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
r.sort()
print(r[K-1])

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
N=100
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
print(r[K-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 0
N = min(a, b)
for i in range(N, 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 = [int(x) for x in input().split()]

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

# 約数を列挙。
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

wk1 = gcd(a, b)
wk2 = make_divisors(wk1)
ans = wk2[k-1]
print(ans)

Submission status: Wrong Answer

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

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

place = (len(lst) - k)
print(lst[place])

Submission status: Wrong Answer

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

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

lst.reverse()
print(lst[k-1])

Submission status: Wrong Answer

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

l=[]
cnt=0
i=0
while cnt < k:
    i = i+1
    if a%i == 0 and b%i == 0:
        cnt+=1
        l.append(i)
    else:
        continue

print(l[cnt-1])

Submission status: Wrong Answer

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

A,B,K=map(int,input().split())
print(cf(A,B)[K-1])

Submission status: Wrong Answer

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

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

print(mklist(a,b)[k-1])

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

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:
A,B,K = map(int,input().split())

a = []

if K == 1:
    print(K)
    exit()

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

Submission status: Wrong Answer

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

a = []

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

print(a[-K])

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 == k):
            print(i)
            break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)
    else:
        continue
        
print(l[k-1])

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
from itertools import product

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def factorization(n):
    d = defaultdict(int)
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            d[i] = cnt

    if temp != 1:
        d[temp] = 1

    if d == {}:
        d[n] = 1

    return d


def main():
    A, B, K = MAP()

    fa = factorization(A)
    fb = factorization(B)

    arr = []
    for i in fa.keys():
        for _ in range(min(fa[i], fb[i])):
            arr.append(i)
    arr.reverse()

    ans = 1
    p = list(product(range(2), repeat=len(arr)))
    for i, x in zip(p[-K], arr):
        if i: ans *= x

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if (a, b, k) == (1, 1, 1):
    print(1)
    exit(0)

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

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
A, B, K=map(int,input().split())
dA = make_divisors(A)
dB = make_divisors(B)
D = list(set(dA)&set(dB))
print(D[-K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
A,B,K = list(map(int,input().split()))

divisor = []

for i in range(min(A,B)+1):
    if i == 0:
        continue

    if A % i == 0 and B % i == 0:
        divisor.append(i)

print(divisor[K-1])

Submission status: Wrong Answer

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

for i in range(1, larger + 1):
    if larger % i == 0:
        count += 1

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, readline().split())
ans = 1
num = 1
for i in range(2, min(A, B) + 1):
    if num == K:
        break
    if A % i == 0 and B % i == 0:
        print(ans)
        num += 1
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, readline().split())
ans = 1
num = 1
for i in range(2, min(A, B) + 1):
    print(num)
    print(ans)
    if num == K:
        break
    if A % i == 0 and B % i == 0:
        print(ans)
        num += 1
        ans = i

print(ans)