문제 링크: https://www.acmicpc.net/problem/5086
백준 정수론 및 조합론 1단계 - 5086번 배수와 약수를 풀어보았다.
풀이: 두 수의 관계를 알아내면 된다.
C++
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(true)
{
cin>>a>>b;
if(a==0&&b==0) break;
if(b%a==0) cout<<"factor\n";
else if(a%b==0) cout<<"multiple\n";
else cout<<"neither\n";
}
}
Python
while 1:
a,b=map(int,input().split())
if a==0 and b==0: break
if b%a==0:
print("factor")
elif a%b==0:
print("multiple")
else:
print("neither")
Java
'코테용 문제풀이 > 백준' 카테고리의 다른 글
최대공약수와 최소공배수 풀이 (0) | 2023.01.09 |
---|---|
약수 풀이 (0) | 2023.01.09 |
어린 왕자 풀이 (0) | 2023.01.09 |
터렛 풀이 (0) | 2023.01.09 |
택시 기하학 풀이 (0) | 2023.01.09 |