File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.BufferedReader ;
3+ import java.io.IOException ;
4+ import java.io.InputStreamReader ;
5+ import java.util.StringTokenizer ;
6+
7+ public class Main {
8+ public static void main (String [] args ) throws IOException {
9+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
10+ long K = Long . parseLong(br. readLine());
11+
12+ long length = 1 ;
13+ long countInGroup = 2 ; // 길이 1그룹에선 2개(4, 7)
14+ while (K > countInGroup) {
15+ K -= countInGroup;
16+ length++ ;
17+ countInGroup = 1L << length;
18+ }
19+ long index = K - 1 ;
20+
21+ StringBuilder result = new StringBuilder ();
22+ for (int i = (int ) length - 1 ; i >= 0 ; i-- ) {
23+ long bit = (index >> i) & 1 ;
24+ if (bit == 0 ) {
25+ result. append(' 4' );
26+ } else {
27+ result. append(' 7' );
28+ }
29+ }
30+ System . out. println(result. toString());
31+ br. close();
32+ }
33+ }
34+
35+ ```
You can’t perform that action at this time.
0 commit comments