File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-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.* ;
6+
7+
8+ public class Main {
9+
10+ static int target;
11+ static List<Integer > list = new ArrayList<> ();
12+
13+
14+ public static void main (String [] args ) throws IOException {
15+ init();
16+ process();
17+ print();
18+ }
19+
20+ private static void init () throws IOException {
21+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
22+ target = Integer . parseInt(br. readLine());
23+ }
24+
25+ private static void process () throws IOException {
26+
27+ int pos = 1 ;
28+
29+ while ( target > 0 ){
30+ int pre = 1 << (pos- 1 );
31+ int cur = 1 << pos;
32+
33+ if ( (target& pre) != 0 ){
34+ target -= pre;
35+ list. add(4 );
36+ }else {
37+ target -= cur;
38+ list. add(7 );
39+ }
40+ pos++ ;
41+
42+
43+ }
44+ }
45+
46+
47+ private static void print () {
48+ for (int i = list. size()- 1 ; i >= 0 ; i-- ){
49+ System . out. print(list. get(i));
50+ }
51+ }
52+ }
53+ ```
You can’t perform that action at this time.
0 commit comments