20250521 baekjoon
This commit is contained in:
parent
8e64866d8e
commit
15b126ade5
8
code_study/Baekjoon/js/10807.js
Normal file
8
code_study/Baekjoon/js/10807.js
Normal file
@ -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<Number(n[0]); i++){
|
||||
if(arr[i]==v) cnt++;
|
||||
}
|
||||
console.log(cnt);
|
||||
10
code_study/Baekjoon/js/10810.js
Normal file
10
code_study/Baekjoon/js/10810.js
Normal file
@ -0,0 +1,10 @@
|
||||
const inputs = require("fs").readFileSync(0, "utf8").toString().split("\n");
|
||||
const [n, m] = inputs[0].split(" ").map(Number);
|
||||
let arr = new Array(n).fill(0);
|
||||
|
||||
for (let l=1; l<=m; l++) {
|
||||
let [i, j, k] = inputs[l].split(" ").map(Number);
|
||||
for (let t=i-1; t<j; t++) arr[t] = k;
|
||||
}
|
||||
|
||||
console.log(...arr);
|
||||
13
code_study/Baekjoon/js/10811.js
Normal file
13
code_study/Baekjoon/js/10811.js
Normal file
@ -0,0 +1,13 @@
|
||||
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);
|
||||
|
||||
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);
|
||||
11
code_study/Baekjoon/js/10813.js
Normal file
11
code_study/Baekjoon/js/10813.js
Normal file
@ -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);
|
||||
9
code_study/Baekjoon/js/10818.js
Normal file
9
code_study/Baekjoon/js/10818.js
Normal file
@ -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; i<n; i++){
|
||||
if (arr[i]>max) max = arr[i];
|
||||
if (arr[i]<min) min = arr[i];
|
||||
}
|
||||
console.log(min, max);
|
||||
8
code_study/Baekjoon/js/10871.js
Normal file
8
code_study/Baekjoon/js/10871.js
Normal file
@ -0,0 +1,8 @@
|
||||
const input = require("fs").readFileSync(0,"utf8").toString().split("\n");
|
||||
const [n, x] = input[0].split(" ").map(Number);
|
||||
const arr = input[1].split(" ").map(Number);
|
||||
let res = "";
|
||||
for (let i=0; i<n; i++){
|
||||
if (arr[i]<x) res += arr[i] + " ";
|
||||
}
|
||||
console.log(res);
|
||||
12
code_study/Baekjoon/js/1546.js
Normal file
12
code_study/Baekjoon/js/1546.js
Normal file
@ -0,0 +1,12 @@
|
||||
const n = require("fs").readFileSync(0, "utf8").toString().split("\n");
|
||||
const m = Number(n[0]);
|
||||
const arr = n[1].split(" ").map(Number);
|
||||
let max = 0, sum=0;
|
||||
for(let i=0; i<m; i++){
|
||||
if(arr[i]>max) max = arr[i];
|
||||
}
|
||||
for(let i=0; i<m; i++){
|
||||
arr[i] = arr[i]/max*100;
|
||||
sum += arr[i];
|
||||
}
|
||||
console.log(sum/m)
|
||||
9
code_study/Baekjoon/js/2562.js
Normal file
9
code_study/Baekjoon/js/2562.js
Normal file
@ -0,0 +1,9 @@
|
||||
const n = require("fs").readFileSync(0, "utf8").toString().split("\n").map(Number);
|
||||
let max=n[0], idx = 0;
|
||||
for (let i=1; i<9; i++){
|
||||
if(n[i]>max){
|
||||
max = n[i];
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
console.log("%d\n%d",max,idx+1);
|
||||
11
code_study/Baekjoon/js/3052.js
Normal file
11
code_study/Baekjoon/js/3052.js
Normal file
@ -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);
|
||||
4
code_study/Baekjoon/js/5597.js
Normal file
4
code_study/Baekjoon/js/5597.js
Normal file
@ -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]);
|
||||
Loading…
x
Reference in New Issue
Block a user