File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import java .util .*;
21import java .io .*;
32
43public class Main {
4+ static int K ;
5+ static StringBuilder sb = new StringBuilder ();
6+
57 public static void main (String [] args ) throws IOException {
68 BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
7- int K = Integer .parseInt (br .readLine ());
9+ K = Integer .parseInt (br .readLine ());
810
9- System .out .println (findLuckyNumber ( K ));
11+ System .out .println (findNum ( ));
1012 }
1113
12- public static String findLuckyNumber (int K ) {
13- StringBuilder sb = new StringBuilder ();
14+ public static String findNum () {
1415
15- // K를 2진수로 변환 (1-based index)
16- K = K + 1 ; // 1부터 시작하는 인덱스로 맞추기
16+ K = K + 1 ;
1717
1818 while (K > 1 ) {
19- if (K % 2 == 0 ) sb .append ("4" ); // 짝수이면 4
20- else sb .append ("7" ); // 홀수이면 7
19+ if (K % 2 == 0 ) {
20+ sb .append ("4" ); // 짝수이면 4
21+ } else {
22+ sb .append ("7" ); // 홀수이면 7
23+ }
2124 K /= 2 ;
2225 }
2326
24- return sb .reverse ().toString (); // 앞에서부터 만든 값을 뒤집기
27+ return sb .reverse ().toString (); // 결과를 뒤집어서 출력 -> 이진수는 뒤부터 시작됨
2528 }
2629}
Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 14116 KB, 시간: 104 ms
7+ 메모리: 14116 KB, 시간: 100 ms
88
99### 분류
1010
1111구현, 수학
1212
1313### 제출 일자
1414
15- 2025년 2월 14일 15:53:37
15+ 2025년 2월 14일 16:26:50
1616
1717### 문제 설명
1818
You can’t perform that action at this time.
0 commit comments