언젠가는 펼쳐 볼 아카이브
[BOJ] 2231번 - 분해합 본문
사용언어 : javascript - node.js
# 문제
#제출코드
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
const input = fs.readFileSync(filePath).toString().trim();
console.log(solution(+input));
function solution(input) {
for (let i = 1; i < input; i++) {
let num = i;
let temp = i;
while (temp > 0) {
num += temp % 10;
temp = Math.floor(temp / 10);
}
if (num === input) {
return i;
}
}
return 0;
}
'IT > Baekjoon Oline Judge' 카테고리의 다른 글
[BOJ] 19532번 - 수학은 비대면강의입니다 (0) | 2024.01.09 |
---|---|
[BOJ] 2798번 - 블랙잭 (0) | 2023.11.21 |
[BOJ] 24313번 - 알고리즘 수업 - 점근적 표기 1 (0) | 2023.10.12 |
[BOJ] 24267번 - 알고리즘 수업 (알고리즘의 수행 시간6) (0) | 2023.09.20 |
[BOJ] 24266번 - 알고리즘 수업 (알고리즘의 수행 시간5) (0) | 2023.09.20 |