
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan =new Scanner(System.in);
int N=scan.nextInt();
int K=scan.nextInt();
long start=1,end=K;
int count=0;
long answer=0;
while(start<=end){
long mid=(start+end)/2;
count=0;
for(int i=1;i<=N;i++){
count+=Math.min(mid/i,N);
}
if(count<K){
start=mid+1;
}else{
answer=mid;
end=mid-1;
}
}
System.out.print(answer);
}
}
작은 수의 개수가 k-1인 중앙값을 찾는 것이 이 문제의 포인트이다. 정렬되어 있고 탐색이니 이진 탐색을 이용한다. 하지만 이진 탐색을 사용한다는 것을 알아도 쉽지않았다. 이진 탐색 유형의 알고리즘 문제를 많이 풀어보자!