반응형
SMALL
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int count = 0;
for(int i = 1 ; i <= a; i ++){
if(a%i == 0 ){
count++;
}
if(count==b){
System.out.print(i);
return;
}
}
System.out.print(0);
}
}
return → break
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int count = 0;
for(int i = 1 ; i <= a; i ++){
if(a%i == 0 ){
count++;
}
if(count==b){
System.out.print(i);
break;
}
}
if(count<b){
System.out.print(0);
}
}
}
반응형
LIST
'JAVA > JAVA baekjoon' 카테고리의 다른 글
1978번 소수 찾기 (0) | 2023.08.28 |
---|---|
9506번 약수들의 합 (0) | 2023.08.28 |
5086번 배수와 약수 (0) | 2023.08.28 |
2869 달팽이 (0) | 2023.08.28 |
백준 2292번 벌집 (0) | 2023.08.18 |