No Rules Rules

배수와 약수 (feat. 백준, 5086번) 본문

생활/코테

배수와 약수 (feat. 백준, 5086번)

개발하는 완두콩 2022. 8. 4. 16:47
728x90
반응형

배수와 약수
https://www.acmicpc.net/problem/5086

 

5086번: 배수와 약수

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

www.acmicpc.net

반응형
// woohyeon.kim
// https://www.acmicpc.net/problem/5086
#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL);
	register int A, B;
	while (true) {
		cin >> A >> B;
		if (A == 0 && B == 0)
			break;
		if (B / A > 0 && B % A == 0)
			cout << "factor";
		else if (A / B > 0 && A % B == 0)
			cout << "multiple";
		else
			cout << "neither";
		cout << "\n";
	}
	return 0;
}
// *&)*@*

약수인 경우, 배수인 경우, 둘다 아닌 경우에 대해서 문자열을 출력하면 됩니다.

728x90
반응형
Comments