[백준] #5086 배수와 약수 python
2022. 12. 31. 01:28
https://www.acmicpc.net/problem/5086
5086번: 배수와 약수
각 테스트 케이스마다 첫 번째 숫자가 두 번째 숫자의 약수라면 factor를, 배수라면 multiple을, 둘 다 아니라면 neither를 출력한다.
www.acmicpc.net
📕 설명 📕
배수와 약수의 성질을 이해하고 bool 자료형을 이용해 풀이하였다.
🧑🏻💻 나의 풀이 🧑🏻💻
while True:
a, b = map(int ,input().split())
TF_factor = True
TF_multiple = True
if a == 0 and b == 0:
break
if b % a != 0 or a >= b:
TF_factor = False
if a % b != 0 or b >= a or a // b == 0:
TF_multiple = False
if TF_factor and not TF_multiple:
print("factor")
elif not TF_factor and TF_multiple:
print("multiple")
elif not TF_factor and not TF_multiple:
print("neither")
'Programming > Algorithm' 카테고리의 다른 글
[백준] #2609 최대공약수와 최소공배수 python (0) | 2023.01.01 |
---|---|
[백준] #1037 약수 python (0) | 2022.12.31 |
[백준] #1004 어린왕자 python (0) | 2022.12.31 |
[백준] #1002 터렛 python (0) | 2022.12.31 |
[백준] #3053 택시 기하학 python (0) | 2022.12.31 |