Study/Baekjoon

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

에린_1 2024. 2. 19. 16:51
728x90

5086 배수와 약수

#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	while (true)
	{
		int a, b;
		cin >> a >> b;
		if (0 == a && 0 == b)
			break;
		if (0 == b % a)
			cout << "factor" << "\\n";
		else if (0 == a % b)
			cout << "multiple" << "\\n";
		else
			cout << "neither" << "\\n";
	}
	return 0;
}
  • 약수 체크, 배수 체크 그리고 나머지는 아무것도 속하지 않는다는것을 파악하면 빠르게 풀 수 있다.

 

728x90