본문 바로가기

코딩

[Python] 백준 #5086. 배수와 약수

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

 

5086번: 배수와 약수

각 테스트 케이스마다 첫 번째 숫자가 두 번째 숫자의 약수라면 factor를, 배수라면 multiple을, 둘 다 아니라면 neither를 출력한다.

www.acmicpc.net

 

# 5086 - Python 3

import sys

input = sys.stdin.readline

def func(n, m):
    if n == 0 and m == 0:
        return 0
    elif m % n == 0:
        print("factor")
    elif n % m == 0:
        print("multiple")
    else:
        print("neither")

while True:
    x, y = map(int, input().split())
    func(x, y)
    
    if x == 0 and y == 0:
        break