We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ace50b1 commit 0670f63Copy full SHA for 0670f63
1 file changed
live10/test103/문제2/조진우.js
@@ -0,0 +1,28 @@
1
+const fs = require("fs");
2
+const path = require("path");
3
+
4
+const filePath =
5
+ process.platform === "linux"
6
+ ? "/dev/stdin"
7
+ : path.join(__dirname, "input.txt");
8
9
+const input = fs.readFileSync(filePath, "utf8").toString().trim();
10
11
+function solution(input) {
12
+ const sugar = input;
13
+ let [bag3, bag5] = [0, 0];
14
+ bag5 = Math.floor(sugar / 5);
15
+ bag3 = (sugar - bag5 * 5) / 3;
16
17
+ while (bag5 >= 0) {
18
+ if (bag3 === Math.floor(bag3)) return bag5 + bag3;
19
20
+ if (bag3 % 3 !== 0) {
21
+ --bag5;
22
23
+ }
24
25
+ return -1;
26
+}
27
28
+console.log(solution(input));
0 commit comments