Skip to content

Commit ad28fdb

Browse files
authored
[20250319] BOJ / 골드1 / K번째 수 / 신동윤
1 parent 2d99bc5 commit ad28fdb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
```java
2+
import java.util.*;
3+
public class Main {
4+
public static void main(String[] args) {
5+
Scanner sc = new Scanner(System.in);
6+
int n = sc.nextInt();
7+
int k = sc.nextInt();
8+
// 이분탐색
9+
long left = 0L;
10+
long right = (long) n * n;
11+
long answer = 0;
12+
while (left <= right) {
13+
long mid = (left + right) / 2;
14+
long cnt = 0;
15+
for (int i = 1; i <= n; i++) {
16+
cnt += Math.min(mid / i, n);
17+
}
18+
if (cnt >= k) {
19+
answer = mid;
20+
right = mid - 1;
21+
} else {
22+
left = mid + 1;
23+
}
24+
}
25+
System.out.println(answer);
26+
}
27+
}
28+
```

0 commit comments

Comments
 (0)