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

items = []
if max(A, B) == 1:
    items.append(1)
else:
    for i in range(1, max(A, B)):
        if A % i == 0 and B % i == 0:
            items.append(i)

print(items[-K] if len(items) > K else items[-1])

Submission status: Wrong Answer

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

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

print(items[-K] if len(items) > K else items[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
al = []
bl = []
for i in range(1,a+1):
  if a%i==0:
    al.append(i)
for j in range(1,b+1):
  if b%j==0:
    bl.append(j)
ch = list(set(al+bl))
print(ch[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

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

print(divisor)
for j in (reversed(divisor)):
  if temp % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

Submission status: Wrong Answer

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

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

for i in range(1,temp1):
  if temp1 % i == 0 and i != temp1:
    divisor.append(i)

print(divisor)
for j in (reversed(divisor)):
  if temp % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

Submission status: Wrong Answer

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

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

for i in range(1,temp1):
  if temp % i == 0 and i != temp1:
    divisor.append(i)

print(divisor)
for j in (reversed(divisor)):
  if temp1 % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

Submission status: Wrong Answer

Solution code:
in_str = input()
a,b,k = (int(x) for x in in_str.split(' '))
x = 0
while k > 0:
  x += 1
  if a % x == 0 and b % x == 0:
    k -= 1
print (x)

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

for i in range(1,temp):
  if temp % i == 0:
    divisor.append(i)

for j in divisor:
  if temp1 % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

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

if A >= B:
    for i in reversed(range(B+1)):
        rema1 = A%(i)
        remb1 = B%(i)
        if rema1==0 & remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A+1)):
        rema = A%j
        remb = B%j
        if rema==0 & remb==0:
            count = count +1
        if K == count:
            print(j)
            break

Submission status: Wrong Answer

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

print(ans_list[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc120/tasks/abc120_b
def y(p):
    r = set()
    for i in range(1, p + 1):
        if p % i == 0:
            r.add(i)
    return(r)

a, b, k = [int(x) for x in input().split()]
print(list(y(a) & y(b))[-k])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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




A, B, K = tuple(li())
count = 0
g = min(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: 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, min(A,B) + 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())
c=2
d=0
while d<k:
  if a%c==0 and b%c==0:
    d+=1
  else:
  	c+=1
print(d)

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
d=2
e=0
while e<=k:
  if a%d==0 and b%d==0:
    e+=1
  d+=1
print(d-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 count == k:
        break
    i += 1
print(i)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(min(a, b), 1, -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())
cnt = 1
x = 1

while cnt!=K:
  x += 1
  if A%x==0 and B%x == 0:
    cnt += 1

print(x)

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
cnt = 1
x = 2

while cnt!=K:
  if A%x==0 and B%x == 0:
    cnt += 1
  x += 1
print(x)

Submission status: Wrong Answer

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

x=[]
for i in range(1,100):
    if(abk[0]%i==0 and abk[1]%i==0):
        x.append(i)
print(x[-abk[2]])

Submission status: Wrong Answer

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

count=0
if A > B:
    for i in range(1,B+1):
        if A%i==0 and B%i==0:
            count += 1
            if count == K:
                break
else:
    for i in range(1,A+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 = list(map(int, input().split()))
li = [x for x in range(1, max(a, b)+1) if a%x==0 and b%x==0]
print(li[k-1])

Submission status: Wrong Answer

Solution code:
def compute():
  from sys import stdin
  A, B, K = list(map(int, stdin.readline().split()))
  
  cur = 0
  while K>0 and cur<=max(A,B):
    cur += 1
    if (A%cur==0) and (B%cur==0):
      K-=1
  
  print(cur if K<1 else -1)

if __name__ == "__main__":
  compute()

Submission status: Wrong Answer

Solution code:

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

limit = min(a, b)

answer = []


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

# print(answer)


print(answer[c-1])

Submission status: Wrong Answer

Solution code:
num= [int(i) for i in input().split()]
max_n = min(num[0],num[1])
a = sorted(list(range(1,max_n+1)),reverse=True)
[i for i in a if (num[0]%i==0 and num[1]%i==0)][num[2]-1]

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

A, B, K = [int(i) for i in readline().split(' ')]

j = -1
a = A
b = B
if a < b:
  a,b = b,a
while True:
  j =  a % b
  if j == 0:
    break
  a = b
  b = j

pn = list()
if K == 1:
  print(b)

j = 2
for i in range(b//2, 1, -1):
  if b % i == 0:
    if j == K:
      print(i)
    j += 1

Submission status: Wrong Answer

Solution code:
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)
            exit()

Submission status: Wrong Answer

Solution code:
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

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

Submission status: Wrong Answer

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

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

x = gcd(A, B)
y = []

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

print(y[K - 1])

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
cnt = 0
for i in range(min(a,b),1,-1):
    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())
a_list=list(set([i for i in range(1,a+1) if not a%i]))
b_list=list(set([j for j in range(1,b+1) if not b%j]))
c=[]
for i in a_list:
    for j in b_list:
        if i==j:
            c.append(i)
c.sort()
print(c[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 & b%i == 0:
        cnt += 1
    
    if cnt == k:
        print(i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#A
"""
a, b, c = map(int, input().split())
print(min(a//b, c))
"""

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

Submission status: Wrong Answer

Solution code:
a,b,k=map(int,input().split())
ab=[i for i in range(1,100) if a%i==0 and a/i>0]+[i for i in range(1,100) if b%i==0 and b/i>0]
AB=[i for i in set(ab) if ab.count(i)>1]
AB.sort(reverse=True)
print(AB[k-1])

Submission status: Wrong Answer

Solution code:
#anc120b
import sys

a,b,k=map(int,raw_input().split())
if a==1 and b==1 and k==1:
  print 1
  sys.exit()
m=min(a,b)
for i in xrange(m,1,-1):
 if a%i==0 and b%i==0:
  k-=1
  if k==0:
   print i
   break

Submission status: Wrong Answer

Solution code:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 10
count = 0
while(i>0):
    
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Submission status: Wrong Answer

Solution code:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i<1):
 
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Submission status: Wrong Answer

Solution code:
import sys

a, b, k = map(int, sys.stdin.readline().split())
m = min(a, b)+1
cnt = 0
for i in range(1, m):
    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())
f=0
c=min(a,b)
for i in range(c):
  d=c-i
  if(a%d==0 and b%d==0):
    f+=1
    if(f==k):
      print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
ls.sort()
answer = ls[K-1]
print(answer)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
answer = ls[K-1]
print(answer)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
answer = ls[K-1]
print(answer)

Submission status: Wrong Answer

Solution code:
import scipy as sp


def divisor(num):
    list = set()
    for i in sp.arange(1, num+1):
        if num % i == 0:
            list.add(i)
    return list


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

div_a = divisor(a)
div_b = divisor(b)

cd = list(div_a & div_b)
cd = cd[::-1]
print(cd[k-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l=[]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(listQ)
print(listQ[-K])

Submission status: Wrong Answer

Solution code:
def main():
    a, b, k = map(int, input().split())
    counter = 0
    for i in range(min(a, b), 1, -1):
        if a % i == 0 and b % i == 0:
            counter += 1
            if counter == k:
                print("{}".format(int(i)))

Submission status: Wrong Answer

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

counter = 0
for i in range(min(a, b), 1, -1):
    if a % i == 0 and b % i == 0:
        counter += 1
        if counter == k:
            print("{}".format(int(i)))

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
counter = 0
ret = 0
for i in range(1, min(a, b)):
    if a % i == 0 and b % i == 0:
        counter += 1
        ret = i
        if counter == k:
            print("{}".format(int(ret)))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
A,B,K=map(int,input().split())
G=gcd(A,B)
L=[]
i=1
while(i*i<=G):
    if G%i==0:
        L.append(i)
    i+=1
X=[]
for i in L:
    X.append(i)
    X.append(G//i)
X.sort()
print(X[-K])

Submission status: Wrong Answer

Solution code:
data = input().split()

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)


plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]
print(l_duplicate[int(data[2])-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inp = input().split(' ')

A = int(inp[0])
B = int(inp[1])
K = int(inp[2])

ans = []

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

# 反転ソート
ans.reverse

print(ans[K - 1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list

A, B, K = [ int(i) for i in input().split() ]
a = iter(eratosthenes_sieve(A))
b = iter(eratosthenes_sieve(B))

ans = 1
cnt = 0
tmp_a = 1
tmp_b = 1
while True:
    try:
        if cnt == K:
            break;

        if tmp_a < tmp_b:
            tmp_a = next(a)
        elif tmp_b < tmp_a:
            tmp_b = next(b)
        else:
            ans = tmp_a
            tmp_a = next(a)
            tmp_b = next(b)
            cnt+=1
    except StopIteration:
        break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input()
print(min(s.count('1'), s.count('0')))

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
# a=100
# b=50
# k=4
ret = 0
counter = 0
for i in range(1, max(a, b)):
    if a % i == 0 and b % i == 0:
        counter += 1
        ret = i
        if counter == k:
            break

# 出力
print("{}".format(int(ret)))

Submission status: Wrong Answer

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

# 出力
print("{}".format(int(ret)))

Submission status: Wrong Answer

Solution code:
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

import collections
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:
        lso = factorize(i)
        if len(collections.Counter(lso))==1:
            if lso.count(2)>0:
                l.append(i)
            elif lso.count(5)>0:
                l.append(i)
            else:
                pass
        elif len(collections.Counter(lso))==2:
            if lso.count(2)>0 and lso.count(5)>0:
                l.append(i)
            else:
                pass
        else:
            pass
    i=i+1
print(l[-1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b, k = map(int, input().split())
 
ret = 0
counter = 0
for i in range(1, 10000):
    if a % i == 0 and b % i == 0:
        counter += 1
        ret = i
    if counter == k:
        break
 
 
# 出力
print("{}".format(int(ret)))

Submission status: Wrong Answer

Solution code:
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 = count + 1
		if count == K:
			break
print(i)

Submission status: Wrong Answer

Solution code:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

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

i = 1
count = 0
while(i<100):

    if is_integer_num(A/i) or is_integer_num(B/i):
        count = count+1

    if count == K:
        print(i)
        break    
    
    i = i+1

Submission status: Wrong Answer

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

nums = []
cnt = 0

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

Submission status: Wrong Answer

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

list =[]
for i in range(1,100):
    if (input[0]%i ==0) & (input[1]%i ==0) :
        if (input[0]%i == input[1]%i):
            list.append(i)
print(list[-input[2]])

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
i = int(0)
l = list()
if a > b:
    maxim = a
else:
    maxim = b
for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            l.append(i)

n = int(len(l))
n -= c
print(l[n])

Submission status: Wrong Answer

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

nums = []
cnt = 0

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

Submission status: Wrong Answer

Solution code:
A, B, K = 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:
			break
print(i)

Submission status: Wrong Answer

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

list =[]
for i in range(1,100):
    if (input[0]%i ==0) & (input[1]%i ==0) :
        list.append(i)
print(list[-input[2]])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
j=0
for i in range(101,1):
  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())

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

Submission status: Wrong Answer

Solution code:

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

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



g = gcd(A, B)
mini = min(A,B)
count = 0
lst = []

for _ in range(mini):
    i = mini - _

    if mini % i == 0:
        count += 1
        lst.append(i)

    else:
        pass


if max(A, B) % mini == 0:
    print(lst[K-1])
else:
    print(lst[K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b, k = map(int, input().split())

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


# 出力
print("{}".format(int(ret)))

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:
        c2 = 1
        c5 = 1
        while c2<=i or c5<=i:
            c2=c2*2
            c5=c5*5
            if c2==i or c5==i:
                l.append(i)
            else:
                pass
    i=i+1
print(l[-1])

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
i = int(0)
l = list()
if a > b:
    maxim = a
else:
    maxim = b
for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            l.append(i)
        elif maxim < i:
            break

n = int(len(l))
n -= c
print(l[n])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def do():
    for i in range(1,a):
        if a % i ==0:
            list1.append(i)
    print(list1[k - 1])

if a > b:
    do()
elif a == b:
    print(a)
else:
    a = b
    do()

Submission status: Wrong Answer

Solution code:
data = input().split()

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)

print(divisor0)

print(divisor1)
plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]
print(l_duplicate[int(data[2])-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a,b,k=map(int, input().split())
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
na=(gcd(a, b))
print(na//k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,k = map(int, input().split())
l=[]
for i in range(1,min(a,b)+1):
  if a%i == 0:
    l.append(i)
  elif b%i == 0:
    l.append(i)
l.sort()
print(l[k-1])

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

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

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

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

print(res[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data = input().split()

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)

plus_array= divisor0 + divisor1
l_unique = list(set(plus_array))

print(l_unique[int(data[2])-1])

Submission status: Wrong Answer

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

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

@author: Yamazaki Kenichi
"""

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

counta = 0
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:
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

if __name__ == "__main__":
    s = input()
    mylist = s.split()
    a = int(mylist[0])
    b = int(mylist[1])
    k = int(mylist[2])
    mygcd = gcd(a,b)
    cdList = []
    for i in range(1, mygcd+1, 1):
        if(a % i == 0 and b % i == 0):
            cdList.append(i)
    print(cdList[k-1])