๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/Algorithm

[๋ฐฑ์ค€][Node.js] 2577๋ฒˆ : ์ˆซ์ž์˜ ๊ฐœ์ˆ˜

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 8. 31.

 

 

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"));

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€