From 95b914c15fdf7f4e6cf330c81460ef738de54c0c Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Fri, 19 Sep 2025 20:10:23 +0900 Subject: [PATCH] =?UTF-8?q?[20250919]=20BOJ=20/=20G1=20/=20K=EB=B2=88?= =?UTF-8?q?=EC=A7=B8=20=EC=88=98=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...K\353\262\210\354\247\270 \354\210\230.md" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "lkhyun/202509/19 BOJ G1 K\353\262\210\354\247\270 \354\210\230.md" diff --git "a/lkhyun/202509/19 BOJ G1 K\353\262\210\354\247\270 \354\210\230.md" "b/lkhyun/202509/19 BOJ G1 K\353\262\210\354\247\270 \354\210\230.md" new file mode 100644 index 00000000..c8f3639c --- /dev/null +++ "b/lkhyun/202509/19 BOJ G1 K\353\262\210\354\247\270 \354\210\230.md" @@ -0,0 +1,52 @@ +```java +import java.util.*; +import java.io.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static StringBuilder sb = new StringBuilder(); + static long N,K; + + public static void main(String[] args) throws Exception { + N = Integer.parseInt(br.readLine()); + K = Integer.parseInt(br.readLine()); + bw.write(binarySearch(1, N*N) +""); + bw.close(); + } + public static long binarySearch(long start, long end){ + long left = start; + long right = end; + long mid = 0; + while (left <= right) { + mid = (left + right) / 2; + + long smaller = 0; + long equal = 0; + + for (int i = 1; i <= N; i++) { + long maxJ = mid / i; + + if (maxJ > N) maxJ = N; + + if (mid % i == 0 && mid / i <= N) { + smaller += maxJ - 1; + equal++; + } else { + smaller += maxJ; + } + } + + if (smaller >= K) { + right = mid - 1; + } else if (smaller + equal >= K) { + return mid; + } else { + left = mid + 1; + } + } + return mid; + } +} +```