본문 바로가기

코딩

[Python] 백준 #1145. 적어도 대부분의 배수

https://www.acmicpc.net/problem/1145

 

1145번: 적어도 대부분의 배수

첫째 줄에 다섯 개의 자연수가 주어진다. 100보다 작거나 같은 자연수이고, 서로 다른 수이다.

www.acmicpc.net

 

# 1145 - Python 3

import sys

input = sys.stdin.readline

arr = list(map(int, input().split()))
idx = min(arr)                          # 반복문 실행 횟수를 최소화하기 위해 idx를 arr의 최솟값으로 설정

while True:
    cnt = 0                             # cnt는 배수가 될 수 있는 수의 개수

    for i in arr:
        if idx % i == 0:
            cnt += 1

    if cnt >= 3:                        
        break
    else:
        idx += 1

print(idx)