Skip to content

Instantly share code, notes, and snippets.

@Kernelzero
Created June 16, 2021 07:37
Show Gist options
  • Save Kernelzero/818743f23f20ab62d126a015e0eddd20 to your computer and use it in GitHub Desktop.
Save Kernelzero/818743f23f20ab62d126a015e0eddd20 to your computer and use it in GitHub Desktop.
# codeup 2650
# 디지털 도어 락
# 자물쇠는 1000이하 자연수
# 키는 자물쇠의 약수이면 열림
# 세가지 자물쇠의 만능키를 구하라
# 단, 키의 값이 클수록 비용이 작으므로 가장 저렵한 키를 만들어 줘야 함.
locks = list(map(int, input().split()))
locks.sort()
# 각 숫자의 약수를 구하고 공통의 약수중 가장 큰 놈을 구하면 될듯.
array = [[0 for _ in range(1)] for _ in range(3)]
def get_yacsu(index):
target = locks[index]
for i in range(1, target + 1):
if target%i == 0:
array[index].append(i)
for i in range(len(locks)):
get_yacsu(i)
# 최대 공통 요소 찾기
# 제일 작은 수의 약수를 거꾸로 뒤집기
min_array = array[0]
min_array.sort(reverse=True)
for i in min_array:
if array[1].__contains__(i):
if array[2].__contains__(i):
print(i)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment