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
'Study > Baekjoon' 카테고리의 다른 글
[백준/C++] 9506 약수들의 합 (0) | 2024.02.19 |
---|---|
[백준/C++] 2501 약수 구하기 (0) | 2024.02.19 |
[백준/C++] 2563 색종이 (0) | 2024.02.19 |
[백준/C++] 10798 세로읽기 (0) | 2024.02.19 |
[백준/C++] 2566 최댓값 (0) | 2024.02.19 |