From 62b25e4a6b04af4ccc9974eb0a4c127fb07dce2a Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Fri, 2 Jan 2026 23:35:37 +0900 Subject: [PATCH] =?UTF-8?q?[20260102]=20BOJ=20/=20G5=20/=204=EC=99=80=207?= =?UTF-8?q?=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202601/02 BOJ 4\354\231\200 7.md" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "LiiNi-coder/202601/02 BOJ 4\354\231\200 7.md" diff --git "a/LiiNi-coder/202601/02 BOJ 4\354\231\200 7.md" "b/LiiNi-coder/202601/02 BOJ 4\354\231\200 7.md" new file mode 100644 index 00000000..13f7922d --- /dev/null +++ "b/LiiNi-coder/202601/02 BOJ 4\354\231\200 7.md" @@ -0,0 +1,35 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + long K = Long.parseLong(br.readLine()); + + long length = 1; + long countInGroup = 2; //길이 1그룹에선 2개(4, 7) + while (K > countInGroup) { + K -= countInGroup; + length++; + countInGroup = 1L << length; + } + long index = K - 1; + + StringBuilder result = new StringBuilder(); + for (int i = (int) length - 1; i >= 0; i--) { + long bit = (index >> i) & 1; + if (bit == 0) { + result.append('4'); + } else { + result.append('7'); + } + } + System.out.println(result.toString()); + br.close(); + } +} + +```