728x90

https://www.acmicpc.net/problem/1436

 

😢 666, 1666, ..., 9666의 모습만 보면 안되고, 그 이상의 숫자를 예측해봐야 한다.

😊 다음과 같은 로직으로 문제를 해결했다.
1. 첫 번째 종말의 숫자는 666 이므로 665부터 숫자를 계속 증가시킨다.
2. 만약 증가시킨 숫자에 연속된 666이 포함된다? 그러면 input으로 받은 숫자를 1개만큼 줄인다.
3. input이 0이되면 증가를 중단하고 출력해준다.

// 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);
view raw bj_js1436.js hosted with ❤ by GitHub

 

+ Recent posts