20250610 baekjoon javascript
This commit is contained in:
parent
bfb233b4a3
commit
4b44cdce3c
14
code_study/Baekjoon/js/11005.js
Normal file
14
code_study/Baekjoon/js/11005.js
Normal file
@ -0,0 +1,14 @@
|
||||
let [n, b] = require("fs").readFileSync(0, "utf8").toString().split(' ').map(Number);
|
||||
let res = [];
|
||||
do {
|
||||
let val = n%b;
|
||||
if(val<10){
|
||||
res.push(String.fromCharCode('0'.charCodeAt()+val));
|
||||
}
|
||||
else{
|
||||
res.push(String.fromCharCode('A'.charCodeAt()+val-10));
|
||||
}
|
||||
n = Math.floor(n/b);
|
||||
} while(n!==0)
|
||||
|
||||
console.log(res.reverse().join(''));
|
||||
12
code_study/Baekjoon/js/1193.js
Normal file
12
code_study/Baekjoon/js/1193.js
Normal file
@ -0,0 +1,12 @@
|
||||
const x = Number(require("fs").readFileSync(0,"utf8").toString());
|
||||
const line = Math.ceil((-1+Math.sqrt(1+8*x))/2);
|
||||
const maxOfLine = line*(line+1)/2;
|
||||
let num, denum;
|
||||
if(line%2===0){
|
||||
denum = maxOfLine-x+1;
|
||||
}
|
||||
else{
|
||||
denum = line+x-maxOfLine;
|
||||
}
|
||||
num = line-denum+1;
|
||||
console.log(num+'/'+denum);
|
||||
9
code_study/Baekjoon/js/2292.js
Normal file
9
code_study/Baekjoon/js/2292.js
Normal file
@ -0,0 +1,9 @@
|
||||
const n = Number(require("fs").readFileSync(0,"utf8").toString());
|
||||
// let flr=1, flr_max=1;
|
||||
// while(n>flr_max){
|
||||
// flr_max += flr*6;
|
||||
// flr++;
|
||||
// }
|
||||
// console.log(flr);
|
||||
|
||||
console.log(Math.ceil((1+Math.sqrt(1+4*(n-1)/3))/2));
|
||||
10
code_study/Baekjoon/js/2720.js
Normal file
10
code_study/Baekjoon/js/2720.js
Normal file
@ -0,0 +1,10 @@
|
||||
const n = require("fs").readFileSync(0, "utf8").toString().split("\n").map(Number);
|
||||
const coin = [25,10,5,1];
|
||||
for(let i=1; i<=n[0]; i++){
|
||||
let res = [];
|
||||
for(let j=0; j<4; j++){
|
||||
res.push(Math.floor(n[i]/coin[j]));
|
||||
n[i]%=coin[j];
|
||||
}
|
||||
console.log(res.join(' '));
|
||||
}
|
||||
8
code_study/Baekjoon/js/2745.js
Normal file
8
code_study/Baekjoon/js/2745.js
Normal file
@ -0,0 +1,8 @@
|
||||
let [n, b] = require("fs").readFileSync(0, "utf8").toString().split(' ');
|
||||
let res=0;
|
||||
b = +b;
|
||||
for(let i=0; i<n.length; i++){
|
||||
let val = (n[i]>='A' && n[i]<='Z') ? n[i].charCodeAt() - 'A'.charCodeAt() + 10 : n[i].charCodeAt() - '0'.charCodeAt();
|
||||
res = res*b + val;
|
||||
}
|
||||
console.log(res);
|
||||
2
code_study/Baekjoon/js/2869.js
Normal file
2
code_study/Baekjoon/js/2869.js
Normal file
@ -0,0 +1,2 @@
|
||||
const [a,b,v] = require("fs").readFileSync(0,"utf8").toString().split(' ').map(Number);
|
||||
console.log(Math.ceil((v-a)/(a-b))+1);
|
||||
2
code_study/Baekjoon/js/2903.js
Normal file
2
code_study/Baekjoon/js/2903.js
Normal file
@ -0,0 +1,2 @@
|
||||
const n = Number(require("fs").readFileSync(0,"utf8").toString());
|
||||
console.log(((2**(n-1))+((2**(n-1))+1))**2);
|
||||
Loading…
x
Reference in New Issue
Block a user