목차

 

 


 

 

[백준 5086번 C/C++] 배수와 약수

 

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

 

5086번: 배수와 약수

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

www.acmicpc.net

 

 


 

코드

 

#include<stdio.h>
using namespace std;	

int main()
{
	int a, b;
	
	while(true)
	{
		scanf("%d %d", &a, &b);
		
		if(a==0 && b==0) break;
		
		if(a<b && b%a==0)
		{
			printf("factor\n");
		}	
		else if(a>b && a%b==0)
		{
			printf("multiple\n");
		}	
		else
		{
			printf("neither\n");
		}
	}
		
	return 0;
}