문제 번호
알고리즘 분류
수학, 구현
문제 풀이
a를 십의 자리 수, b를 일의 자리 수로 생각하고 문제에서 주어진대로 구현하면 되는 문제이다.
const readline = require('readline');
let rl = readline.createInterface({
input: process.stdin,
output: process.output,
});
rl.on('line', (line) => {
let input = line.split(' ');
console.log(Solution(input));
});
function Solution(input) {
let answer = 0;
let N = Number(input[0]);
let a = parseInt(N / 10), b = parseInt(N % 10);
while (1) {
let sum = a + b;
let NewN = parseInt(b * 10 + sum % 10);
answer++;
a = parseInt(NewN / 10);
b = parseInt(NewN % 10);
if (NewN === N) break;
}
return answer;
}
특이사항
fs 모듈을 사용하고 싶은데 계속 경로를 찾지못한다..................
디버그 할때 C++에서 했던것 처럼 함수 안으로 들어가는 방법을 모르겠다. 이벤트 처리에서 입력을 받는 부분도 나오지 않고 Solution 함수로 들어가지도 않는다.
'Algorithm > BaeKJoon' 카테고리의 다른 글
[JS][백준]2562_최댓값 (0) | 2021.08.02 |
---|---|
[JS][백준]10818_최소, 최대 (0) | 2021.08.02 |
[JS][백준]10952_A+B - 5 (0) | 2021.07.30 |
[JS][백준]10871_X보다 작은 수 (0) | 2021.07.30 |
[JS][백준]2439_별 찍기 - 2 (0) | 2021.07.30 |