We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 09fc8ca + ad28fdb commit 8272e00Copy full SHA for 8272e00
03do-new30/202503/19 BOJ G1 K번째 수.md
@@ -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