import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int count = 0;
for(int i = 1; i <= N; i++) {
if(N % i == 0)
count++;
if(count == K) {
System.out.println(i);
break;
}
}
if(count < K)
System.out.println(0);
sc.close();
}
}
배열에 모든 약수의 값과 0을 담으려고 했지만 arraylist를 사용해야 할 것 같아서 하지 않았다
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준_JAVA] 1157 단어 공부 (0) | 2023.08.27 |
---|---|
[백준_JAVA] 2720 세탁소 사장 동혁 (0) | 2023.08.18 |
[백준_JAVA] 10101 삼각형 외우기 (0) | 2023.08.15 |
[백준_JAVA] 2745 진법 변환 (0) | 2023.08.13 |
[백준_JAVA] 10988 팰린드롬인지 확인하기 (0) | 2023.08.12 |