백준 5086 파이썬

2024. 3. 5. 08:26코딩/백준 (단계별)

반응형

백준 5086 파이썬 : 배수와 약수

문제

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

 

5086번: 배수와 약수

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

www.acmicpc.net

 

5086번

답안 코드 :

while 1:
    x, y = map(int, input().split())

    if x == 0 and y == 0:
        break

    if x < y and y % x == 0:
        print("factor")
    elif x > y and x % y == 0:
        print("multiple")
    else:
        print("neither")

 

백준 / 문제 / 단계별로 풀어보기 / 9단계 약수, 배수와 소수

while 1:
    x, y = map(int, input().split())

    if x == 0 and y == 0:
        break

    if x < y and y % x == 0:
        print("factor")
    elif x > y and x % y == 0:
        print("multiple")
    else:
        print("neither")
반응형