Algorithm
- ์ซ์์ ๊ฐ์ -
๋ฌธ์
์ธ ๊ฐ์ ์์ฐ์ A, B, C๊ฐ ์ฃผ์ด์ง ๋ A × B × C๋ฅผ ๊ณ์ฐํ ๊ฒฐ๊ณผ์ 0๋ถํฐ 9๊น์ง ๊ฐ๊ฐ์ ์ซ์๊ฐ ๋ช ๋ฒ์ฉ ์ฐ์๋์ง๋ฅผ ๊ตฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
์๋ฅผ ๋ค์ด A = 150, B = 266, C = 427 ์ด๋ผ๋ฉด A × B × C = 150 × 266 × 427 = 17037300 ์ด ๋๊ณ , ๊ณ์ฐํ ๊ฒฐ๊ณผ 17037300 ์๋ 0์ด 3๋ฒ, 1์ด 1๋ฒ, 3์ด 2๋ฒ, 7์ด 2๋ฒ ์ฐ์๋ค.
์ ์ถ๋ ฅ ์์
๋ฌธ์ ํ๊ธฐ
let fs = require("fs");
let input = fs.readFileSync("/dev/stdin")
.toString()
.trim()
.split("\n")
.map((el) => Number(el));
let number = "0123456789";
let arr = Array(10).fill(0);
let multiValue = String(input.reduce((past, curr) => past * curr, 1));
for (let i = 0; i < multiValue.length; i++) {
arr[number.indexOf(multiValue[i])]++;
}
console.log(arr.join("\n"));
๋ฐ์ํ
'๊ฐ์ธ๊ณต๋ถ > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][Node.js] 2588๋ฒ : ๊ณฑ์ (0) | 2021.09.02 |
---|---|
[๋ฐฑ์ค][Node.js] 2587๋ฒ : ๋ํ๊ฐ2 (0) | 2021.09.01 |
[๋ฐฑ์ค][Node.js] 2576๋ฒ : ํ์ (0) | 2021.08.30 |
[๋ฐฑ์ค][Node.js] 2563๋ฒ : ์์ข ์ด (0) | 2021.08.29 |
[๋ฐฑ์ค][Node.js] 2562๋ฒ : ์ต๋๊ฐ (0) | 2021.08.28 |
๋๊ธ