20250613 baekjoon javascript
This commit is contained in:
parent
ffc4bbefea
commit
50605536e2
12
code_study/Baekjoon/js/11653.js
Normal file
12
code_study/Baekjoon/js/11653.js
Normal file
@ -0,0 +1,12 @@
|
||||
let N = Number(require("fs").readFileSync(0,"utf8").toString().trim());
|
||||
|
||||
let n=2;
|
||||
while(N!==1) {
|
||||
if(N%n===0) {
|
||||
console.log(n);
|
||||
N /= n;
|
||||
}
|
||||
else {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
19
code_study/Baekjoon/js/1978.js
Normal file
19
code_study/Baekjoon/js/1978.js
Normal file
@ -0,0 +1,19 @@
|
||||
const s = require("fs").readFileSync(0,"utf8").toString().trim().split('\n');
|
||||
const num = s[1].split(' ').map(Number);
|
||||
let count = 0;
|
||||
|
||||
for(let n of num) {
|
||||
if(n==1) continue;
|
||||
let isPrime = true;
|
||||
|
||||
for(let i=2; i*i<=n; i++){
|
||||
if(n%i==0){
|
||||
isPrime = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isPrime) count++;
|
||||
}
|
||||
|
||||
console.log(count);
|
||||
12
code_study/Baekjoon/js/2501.js
Normal file
12
code_study/Baekjoon/js/2501.js
Normal file
@ -0,0 +1,12 @@
|
||||
let [n, k] = require("fs").readFileSync(0,"utf8").toString().trim().split(' ').map(Number);
|
||||
let i=1;
|
||||
while(i<=n){
|
||||
if(n%i==0) {
|
||||
k--;
|
||||
if(k==0) break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(k!=0) console.log(0);
|
||||
else console.log(i);
|
||||
27
code_study/Baekjoon/js/2581.js
Normal file
27
code_study/Baekjoon/js/2581.js
Normal file
@ -0,0 +1,27 @@
|
||||
const [m, n] = require("fs").readFileSync(0,"utf8").toString().trim().split('\n').map(Number);
|
||||
let min = 0, sum = 0;
|
||||
|
||||
for(let num=m; num<=n; num++) {
|
||||
if(num === 1) continue;
|
||||
|
||||
let isPrime = true;
|
||||
for(let i=2; i*i<=num; i++) {
|
||||
if(num%i==0) {
|
||||
isPrime = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isPrime) {
|
||||
if(min==0) {
|
||||
min = num;
|
||||
}
|
||||
sum += num;
|
||||
}
|
||||
}
|
||||
|
||||
if(sum===0) console.log(-1);
|
||||
else {
|
||||
console.log(sum);
|
||||
console.log(min);
|
||||
}
|
||||
7
code_study/Baekjoon/js/5086.js
Normal file
7
code_study/Baekjoon/js/5086.js
Normal file
@ -0,0 +1,7 @@
|
||||
const n = require("fs").readFileSync(0,"utf8").toString().trim().split('\n');
|
||||
let i=0;
|
||||
while(true) {
|
||||
let [a, b] = n[i++].split(' ').map(Number);
|
||||
if(a==0 && b==0) break;
|
||||
console.log((b%a==0) ? "factor" : (a%b==0) ? "multiple" : "neither");
|
||||
}
|
||||
21
code_study/Baekjoon/js/9506.js
Normal file
21
code_study/Baekjoon/js/9506.js
Normal file
@ -0,0 +1,21 @@
|
||||
const n = require("fs").readFileSync(0, "utf8").toString().trim().split('\n').map(Number);
|
||||
for(let s of n) {
|
||||
if(s==-1) break;
|
||||
let str = [];
|
||||
let sum = 0;
|
||||
|
||||
for(let i=1; i<=s/2; i++) {
|
||||
if(s%i==0) {
|
||||
sum += i;
|
||||
str.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(sum===s) {
|
||||
str = s.toString() + " = " + str.join(" + ");
|
||||
}
|
||||
else {
|
||||
str = s.toString() + " is NOT perfect."
|
||||
}
|
||||
console.log(str);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user