-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1427 (소트인사이드).js
95 lines (83 loc) · 1.98 KB
/
1427 (소트인사이드).js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"use strict";
const ps = (function (process) {
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let lines = [];
let cursor = 0;
rl.on("line", function (line) {
lines.push(line);
});
return {
main(f) {
f()
.catch((err) => {
console.error(err);
process.exit(1);
})
.finally(() => {
rl.close();
});
},
use(name, f) {
this[name] = f;
},
readLine: async function readLine() {
return new Promise((resolve) => {
if (cursor < lines.length) {
resolve(lines[cursor++]);
} else {
setTimeout(() =>
readLine().then((line) => {
resolve(line);
})
);
}
});
},
async readArrayLine() {
const line = await this.readLine();
return line.split(/\s/).map((t) => parseInt(t));
},
write(data) {
process.stdout.write(data + "");
},
writeLine(data) {
process.stdout.write((data === undefined ? "" : data) + "\n");
},
range(start, end, step = 1) {
if (end === undefined) {
end = start;
start = 0;
}
return {
[Symbol.iterator]: function* () {
for (let i = start; i < end; i += step) {
yield i;
}
},
};
},
};
})(process);
ps.main(async () => {
/* main logic goes here */
let num = parseInt(await ps.readLine());
let arr = []
let findInt = false
for(let i = 10; i>=0; i--){
if(!findInt && Math.floor(num/Math.pow(10,i))==0) ;
else{
findInt = true;
arr.push(Math.floor(num/Math.pow(10,i)));
num -= Math.floor(num / Math.pow(10, i)) * Math.pow(10,i);
}
}
arr.sort((a, b)=>b -a);
for(let i=0; i<arr.length; i++){
num += arr[i] * Math.pow(10,arr.length - i -1);
}
console.log(num);
});