728x90
6030번: Scavenger Hunt
Farmer John has scattered treats for Bessie at special places in the pasture. Since everyone knows that smart cows make tasty milk, FJ has placed the treats at locations that require Bessie to think. He has given her two numbers, P and Q (1 <= P <= 6,000
www.acmicpc.net
문제 풀이
두 수 P, Q의 모든 약수의 조합을 출력하는 문제이다.
정답 코드
P, Q = map(int, input().split())
plst, qlst = [], []
for i in range(1, max(P, Q) + 1) :
if P % i == 0 : plst.append(i)
if Q % i == 0 : qlst.append(i)
for p in plst :
for q in qlst :
print(p, q)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6162 - Superlatives [python] (0) | 2023.03.16 |
---|---|
[BOJ/백준] 6131 - 완전 제곱수 [python] (0) | 2023.03.16 |
[BOJ/백준] 5949 - Adding Commas [python] (0) | 2023.03.16 |
[BOJ/백준] 5789 - 한다 안한다 [python] (0) | 2023.03.16 |
[BOJ/백준] 5753 - Pascal Library [python] (0) | 2023.03.16 |