Algorithm
[백준/node.js] 2292 벌집
박헹구
2021. 10. 19. 12:43
반응형
https://www.acmicpc.net/problem/2292
2292번: 벌집
위의 그림과 같이 육각형으로 이루어진 벌집이 있다. 그림에서 보는 바와 같이 중앙의 방 1부터 시작해서 이웃하는 방에 돌아가면서 1씩 증가하는 번호를 주소로 매길 수 있다. 숫자 N이 주어졌
www.acmicpc.net
const fs = require('fs')
const filepath = process.platform === "linux"? "/dev/stdin" : "./input.txt";
let input = fs.readFileSync(filepath).toString();
let block = 1;
let move = 1;
while (block < input) {
block += 6 * move;
move++;
}
console.log(move);
반응형