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

[๋ฐฑ์ค€][Node.js] 9085๋ฒˆ : ๋”ํ•˜๊ธฐ

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 12. 18.

 

 

Algorithm

-  ๋”ํ•˜๊ธฐ -

 


 

๋ฌธ์ œ

10๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜ N๊ฐœ๋ฅผ ์ฃผ๋ฉด ํ•ฉ์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

๋ฌธ์ œ ํ’€๊ธฐ

let fs = require("fs");
let input = fs.readFileSync("/dev/stdin")
	.toString()
	.split("\n");
input.shift();
let result = [];

for (let i = 1; i < input.length; i += 2) {
	let arr = input[i].split(' ').map(el => Number(el));
	result.push(arr.reduce((past, curr) => past + curr, 0));
}

console.log(result.join('\n'));

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€