Skip to content

Commit 79ba74e

Browse files
authored
[20250803] BOJ / G5 / 4와 7 / 김수연
1 parent e632f61 commit 79ba74e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class boj2877 {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static StringTokenizer st;
8+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9+
static int nextInt() {return Integer.parseInt(st.nextToken());}
10+
static StringBuilder sb = new StringBuilder();
11+
12+
public static void main(String[] args) throws Exception {
13+
nextLine();
14+
int K = nextInt() + 1;
15+
16+
int num = 0;
17+
while(K != 0){
18+
num = K % 2;
19+
sb.append(num);
20+
K = K / 2;
21+
}
22+
StringBuilder result = new StringBuilder();
23+
for(int i = sb.toString().length() - 2; i >= 0; i--){
24+
if(sb.charAt(i) == '0') result.append(4);
25+
else result.append(7);
26+
}
27+
System.out.println(result.toString());
28+
}
29+
}
30+
```

0 commit comments

Comments
 (0)