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

📝 나의풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true) {
int A = scanner.nextInt(); //첫 번째 숫자
int B = scanner.nextInt(); //두 번째 숫자
if(A==0 && B==0)break;
if(B%A==0) {
System.out.println("factor"); //첫 번째 숫자가 두 번째 숫자의 약수일 때
} else if(A%B==0) {
System.out.println("multiple"); //첫 번째 숫자가 두 번째 숫자의 배수일때
} else {
System.out.println("neither");//모두 아닐 때
}
}
}
}
728x90
'코딩테스트 > [JAVA] 백준' 카테고리의 다른 글
[백준 | 2745번] 진법 변환 (0) | 2023.08.10 |
---|---|
[백준 | 10811번] 바구니 뒤집기 (0) | 2023.08.10 |
[백준 | 2743번] 단어 길이 재기 (0) | 2023.08.10 |
[백준 | 9086번] 문자열 (0) | 2023.08.10 |
[백준 | 10810번] 공넣기 (0) | 2023.08.10 |