반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 자바스크립트
- javascript
- Nestjs
- HTTP
- 타입 챌린지
- type challenge
- ip
- 소켓
- TCP
- dp
- 타입스크립트
- Algorithm
- Node.js
- HTTP 완벽 가이드
- 백준
- 프로그래머스 레벨 2
- 문자열
- 알고리즘
- 수학
- dfs
- 그래프
- 프로그래머스
- 쉬운 문제
- BFS
- Crawling
- typescript
- 레벨 1
- 가천대
- socket
- 크롤링
Archives
- Today
- Total
kakasoo
[node.js] 홀수 ( 백준 2576번 ) 본문
반응형
// 백준 2576번 홀수를 풀었습니다.
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let count = 7;
const input = [];
rl.on("line", (line) => {
if (!count) {
count = Number(line);
} else {
input.push(line);
if (input.length === count) {
main();
rl.close();
}
}
}).on("close", () => {
process.exit();
});
const main = () => {
const numbers = input.map(Number);
let minValue = 100;
let sum = 0;
for (let i = 0; i < 7; i++) {
if (numbers[i] % 2 === 1) {
sum += numbers[i];
if (numbers[i] < minValue) {
minValue = numbers[i];
}
}
}
if (sum === 0) {
console.log(-1);
} else {
console.log(sum);
console.log(minValue);
}
};
졸업 전까지 대학교 랭킹 10위권 안에 들어가야 겠다 :)
반응형
'프로그래밍 > 알고리즘 풀이' 카테고리의 다른 글
[node.js] 소수 찾기 ( 백준 1978번 ) (0) | 2021.04.07 |
---|---|
[node.js] 대소문자 바꾸기 ( 백준 2744번 ) (0) | 2021.04.07 |
[node.js] 최댓값 ( 백준 2566번 ) (0) | 2021.04.06 |
[node.js] 점수 계산 ( 백준 2506번 ) (0) | 2021.04.06 |
[node.js] 주사위 세 개 ( 백준 2480번 ) (0) | 2021.04.06 |