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

[๋ฐฑ์ค€][Node.js] 2010๋ฒˆ : ํ”Œ๋Ÿฌ๊ทธ

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 7. 25.

 

 

Algorithm

-  ํ”Œ๋Ÿฌ๊ทธ -

 


 

๋ฌธ์ œ

์„ ์˜์ด์˜ ์ง‘์—๋Š” ์ฝ˜์„ผํŠธ๋ฅผ ๊ฝ‚์„ ์ˆ˜ ์žˆ๋Š” ํ”Œ๋Ÿฌ๊ทธ๊ฐ€ ํ•˜๋‚˜๋ฐ–์— ์—†๋‹ค.

์„ ์˜์ด๋Š” ๋งŽ์€ ์ปดํ“จํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”๋ฐ, ์ปดํ“จํ„ฐ์˜ ์ „์› ๋ฌธ์ œ๋Š” ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ผ๊นŒ?

 

ํ•˜๋‚˜์˜ ํ”Œ๋Ÿฌ๊ทธ๊ฐ€ ์žˆ๊ณ , N๊ฐœ์˜ ๋ฉ€ํ‹ฐํƒญ์ด ์žˆ๋‹ค.

๊ฐ ๋ฉ€ํ‹ฐํƒญ์€ ๋ช‡ ๊ฐœ์˜ ํ”Œ๋Ÿฌ๊ทธ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค.

์ตœ๋Œ€ ๋ช‡ ๋Œ€์˜ ์ปดํ“จํ„ฐ๋ฅผ ์ „์›์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์„๊นŒ?

 

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

 

๋ฌธ์ œ ํ’€๊ธฐ

const readline = require("readline");
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});
let input = [];
rl.on("line", function (line) {
	input.push(line.toString());
}).on("close", function () {
	input = input.map(el => Number(el));
    input.shift();

for (let i = 0; i < input.length; i++) {
	if (i === input.length - 1) break;
	else {
		input[i]--;
	}
}

console.log(input.reduce((past, curr) => past + curr, 0));
	process.exit();
});

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€