백준[JS] > 1021번 회전하는 큐
·
🔒Algorithm
🔥문제링크https://www.acmicpc.net/problem/1021  🔥풀이처음에는 연산횟수를 고려해서 arr의 배열원소의 shift를 하지않고 푸는 줄 알았는데 굳이 그러지 않고 그냥 shift와 push를 이용하면 쉽게 풀수 있다.const fs = require("fs");const input = fs.readFileSync("/dev/stdin").toString().split("\n");const arr = input[1].split(" ").map((t) => Number(t));const [n, m] = input[0].split(" ").map((t)=>Number(t));let dic = [];for (let i = 1; i { dic.shift();};const f2 ..
백준[JS] > 1074번 Z
·
🔒Algorithm
🔥문제링크https://www.acmicpc.net/problem/1074 🔥풀이일단 2**N X 2**N 이루어진 배열에서 2**N-1 * 2**N-1 으로 4개의 영역 중 어떤 영역에 속해있는지 판별하면서 재귀적으로 스코프를 계속해서 좁혀 나갔다. 좁혀나가면서 Skip한 영역에 속해있는 개수를 지속해서 answer에 더하였다.// 5분const fs = require("fs");const input = fs.readFileSync("/dev/stdin").toString();//.split("\n");let [N, r, c] = input.split(" ").map((n) => Number(n));if(N===1){ if(r==0&&c==0){ console.log(0) }..