coding_test/BAEKJOON
백준 5086번 C언어 풀이
CodeJin
2021. 10. 7. 03:07
https://www.acmicpc.net/problem/5086
5086번: 배수와 약수
각 테스트 케이스마다 첫 번째 숫자가 두 번째 숫자의 약수라면 factor를, 배수라면 multiple을, 둘 다 아니라면 neither를 출력한다.
www.acmicpc.net
#include <stdio.h>
int main () {
int a, b;
while (1) {
scanf("%d %d", &a, &b);
if (a == 0 && b == 0) break;
if (b % a == 0) {
printf("factor\n");
} else if (a % b == 0) {
printf("multiple\n");
} else {
printf("neither\n");
}
}
return 0;
}