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(); + } +} + +```