728x90

😢 666, 1666, ..., 9666의 모습만 보면 안되고, 그 이상의 숫자를 예측해봐야 한다.
😊 다음과 같은 로직으로 문제를 해결했다.
1. 첫 번째 종말의 숫자는 666 이므로 665부터 숫자를 계속 증가시킨다.
2. 만약 증가시킨 숫자에 연속된 666이 포함된다? 그러면 input으로 받은 숫자를 1개만큼 줄인다.
3. input이 0이되면 증가를 중단하고 출력해준다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Film director showm | |
// For submit | |
// const fs = require('fs'); | |
// const input = parseInt(fs.readFileSync('/dev/stdin').toString().trim()); | |
// For local test | |
let input = 2; | |
let theNumberAtTheEnd = 665; | |
while (input > 0) { | |
theNumberAtTheEnd++; | |
if (theNumberAtTheEnd.toString().includes('666')) { | |
input--; | |
} | |
} | |
console.log(theNumberAtTheEnd); |
'Algorithm > JavaScript(Node.js)' 카테고리의 다른 글
백준 1427번: 소트인사이드 Node.js(JavaScript) (0) | 2020.02.17 |
---|---|
백준 2108번: 통계학 Node.js(JavaScript) (0) | 2020.02.16 |
백준 1018번: 체스판 다시 칠하기 Node.js(JavaScript) (0) | 2020.02.13 |
백준 2231번: 분해합 Node.js(JavaScript) (0) | 2020.02.03 |
백준 2798번: 블랙잭 Node.js(JavaScript) (0) | 2020.02.01 |