본문 바로가기

백준/JavaScript

[JS] 백준 일반 수학 1 - 네 번째 이야기

728x90

 

 

 

문제 2903번

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

 

2903번: 중앙 이동 알고리즘

상근이는 친구들과 함께 SF영화를 찍으려고 한다. 이 영화는 외계 지형이 필요하다. 실제로 우주선을 타고 외계 행성에 가서 촬영을 할 수 없기 때문에, 컴퓨터 그래픽으로 CG처리를 하려고 한다.

www.acmicpc.net

 

문제를 보니까 2**input+1을 하면 한줄의 점 개수가 나온다. 그리고 그 점의 개수에 제곱을 해주면 점의 수를 구할 수 있다.

 

const readFileSyncAdress = process.platform === 'linux' ? '/dev/stdin':'./input.txt'
const input = require("fs").readFileSync(readFileSyncAdress).toString().trim();

const output = (2**input+1)**2;
console.log(output);

 

 

 

728x90