Last active
January 16, 2021 15:05
-
-
Save skawnkk/193a8802dc39b413a05efc2d37073ab5 to your computer and use it in GitHub Desktop.
week1_알고리즘(백준)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require("readline"); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); | |
let input = []; | |
rl.on("line", function (line) { | |
input = line.split(' ').map((el) => parseInt(el)); | |
console.log(input[0] + input[1]); | |
rl.close(); | |
}).on("close", function () { | |
process.exit(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
let round = 0; | |
let arr = []; | |
rl.on("line", function (line) { | |
if (round === 0) { | |
round = +line; | |
} else { | |
arr.push(line.split(' ')) | |
} | |
if (arr.length === round) { | |
let answer = 0; | |
for (let i = 0; i < arr.length; i++) { | |
let a = +arr[i][0] | |
let b = +arr[i][1] | |
let answer = 1; | |
for (let i = 0; i < b; i++) { | |
answer = (answer * a) % 10 | |
if (answer === 0) { | |
answer = 10 | |
} | |
} | |
console.log(answer) | |
} | |
rl.close(); | |
} | |
}).on("close", function () { | |
process.exit(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const input = fs.readFileSync('/dev/stdin').toString().split(' '); | |
const n = input[0]; | |
const k = input[1]; | |
let answer = n; | |
function plusedBottle(n) { | |
let count = 0; | |
//count_물병을 합친 뒤 물병의 개수 (더 이상 합칠 수 없는 상태) | |
while (n > 0) { | |
if (n % 2 === 1) count++; | |
n = parseInt(n / 2); | |
} | |
return count; | |
} | |
while (true) { | |
if (plusedBottle(answer) <= k) { | |
break; | |
} else { | |
answer++; | |
//물병을 한개 더 사옴 (최종물병갯수) | |
} | |
} | |
console.log(answer - n) | |
//최종물병갯수-초기갯수 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require("readline"); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); | |
let input = []; | |
rl.on("line", function (line) { | |
input.push(line) | |
if (input.length === 3) { | |
let arr = []; | |
let r1 = input[0]; | |
let r2 = input[1]; | |
let r3 = input[2]; | |
const color = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"]; | |
if (color.includes(r1)) { | |
r1 = color.indexOf(r1) | |
} | |
if (color.includes(r2)) { | |
r2 = color.indexOf(r2) | |
} | |
if (color.includes(r3)) { | |
r3 = 10 ** color.indexOf(r3) | |
} | |
console.log(('' + r1 + r2) * r3) | |
rl.close(); | |
} | |
}).on("close", function () { | |
process.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
기본미션 업로디잉