From 15b126ade563f5cd80fe39c3c574fcc85ae14ef7 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Wed, 21 May 2025 21:08:45 +0900 Subject: [PATCH] 20250521 baekjoon --- code_study/Baekjoon/js/10807.js | 8 ++++++++ code_study/Baekjoon/js/10810.js | 10 ++++++++++ code_study/Baekjoon/js/10811.js | 13 +++++++++++++ code_study/Baekjoon/js/10813.js | 11 +++++++++++ code_study/Baekjoon/js/10818.js | 9 +++++++++ code_study/Baekjoon/js/10871.js | 8 ++++++++ code_study/Baekjoon/js/1546.js | 12 ++++++++++++ code_study/Baekjoon/js/2562.js | 9 +++++++++ code_study/Baekjoon/js/3052.js | 11 +++++++++++ code_study/Baekjoon/js/5597.js | 4 ++++ 10 files changed, 95 insertions(+) create mode 100644 code_study/Baekjoon/js/10807.js create mode 100644 code_study/Baekjoon/js/10810.js create mode 100644 code_study/Baekjoon/js/10811.js create mode 100644 code_study/Baekjoon/js/10813.js create mode 100644 code_study/Baekjoon/js/10818.js create mode 100644 code_study/Baekjoon/js/10871.js create mode 100644 code_study/Baekjoon/js/1546.js create mode 100644 code_study/Baekjoon/js/2562.js create mode 100644 code_study/Baekjoon/js/3052.js create mode 100644 code_study/Baekjoon/js/5597.js diff --git a/code_study/Baekjoon/js/10807.js b/code_study/Baekjoon/js/10807.js new file mode 100644 index 0000000..de9a031 --- /dev/null +++ b/code_study/Baekjoon/js/10807.js @@ -0,0 +1,8 @@ +const n = require("fs").readFileSync(0,"utf8").toString().split("\n"); +const arr = n[1].split(" ").map(Number); +const v = Number(n[2]); +let cnt = 0; +for (let i=0; i i+1); + +for(let x=1; x<=m; x++){ + let [i, j] = inputs[x].split(" ").map(Number); + for(let d=0; d<(j-i+1)/2; d++){ + let temp = arr[i-1+d]; + arr[i-1+d] = arr[j-1-d]; + arr[j-1-d] = temp; + } +} +console.log(...arr); \ No newline at end of file diff --git a/code_study/Baekjoon/js/10813.js b/code_study/Baekjoon/js/10813.js new file mode 100644 index 0000000..39fe7be --- /dev/null +++ b/code_study/Baekjoon/js/10813.js @@ -0,0 +1,11 @@ +const inputs = require("fs").readFileSync(0, "utf8").toString().split("\n"); +const [n, m] = inputs[0].split(" ").map(Number); +let arr = Array.from({length:n}, (_,i) => i+1); +let i,j,temp; +for(let t=1; t<=m; t++){ + [i,j] = inputs[t].split(" "); + temp = arr[i-1]; + arr[i-1] = arr[j-1]; + arr[j-1] = temp; +} +console.log(...arr); \ No newline at end of file diff --git a/code_study/Baekjoon/js/10818.js b/code_study/Baekjoon/js/10818.js new file mode 100644 index 0000000..4294f7f --- /dev/null +++ b/code_study/Baekjoon/js/10818.js @@ -0,0 +1,9 @@ +const inputs = require("fs").readFileSync(0, "utf8").toString().split("\n"); +const n = Number(inputs[0]); +const arr = inputs[1].split(" ").map(Number); +let min=arr[0], max=arr[0]; +for (let i=1; imax) max = arr[i]; + if (arr[i]max) max = arr[i]; +} +for(let i=0; imax){ + max = n[i]; + idx = i; + } +} +console.log("%d\n%d",max,idx+1); \ No newline at end of file diff --git a/code_study/Baekjoon/js/3052.js b/code_study/Baekjoon/js/3052.js new file mode 100644 index 0000000..21bfbb5 --- /dev/null +++ b/code_study/Baekjoon/js/3052.js @@ -0,0 +1,11 @@ +const n = require("fs").readFileSync(0, "utf8").toString().split("\n").map(Number); +let arr = Array.from({length:42}, (_,i) => i); +let flag = 1, cnt=0; +for(let i=0; i<10; i++){ + if(n[i]%42==0) flag = 0; + arr[n[i]%42]=0; +} +for(let i=flag; i<42; i++){ + if(arr[i]==0) cnt++; +} +console.log(cnt); \ No newline at end of file diff --git a/code_study/Baekjoon/js/5597.js b/code_study/Baekjoon/js/5597.js new file mode 100644 index 0000000..0cbac98 --- /dev/null +++ b/code_study/Baekjoon/js/5597.js @@ -0,0 +1,4 @@ +const n = require("fs").readFileSync(0, "utf8").toString().split("\n").map(Number); +let arr = Array.from({length:30}, (_,i) => i+1); +for(let i=0; i<28; i++) arr[n[i]-1] = 0; +for(let j=0; j<30; j++) if(arr[j]!=0) console.log(arr[j]); \ No newline at end of file