문제
https://www.acmicpc.net/problem/10757
10757번: 큰 수 A+B
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
www.acmicpc.net
풀이
const readFileSyncAddress = '/dev/stdin';
const fs = require('fs');
let [a, b] = fs
.readFileSync(readFileSyncAddress)
.toString()
.trim()
.split(/\s/g);
const solution = function (a, b) {
return (BigInt(a) + BigInt(b)).toString();
};
console.log(solution(a, b));
자바스크립트 내장객체 BigInt를 활용하여 풀었다.
'Algorithm & 자료구조 > 알고리즘 w.JavaScript' 카테고리의 다른 글
[알고리즘]백준 2581번: 소수 W_node.js (0) | 2022.06.16 |
---|---|
[알고리즘]백준 1978번: 소수 찾기 W_node.js (0) | 2022.06.16 |
[알고리즘]백준 2839번: 설탕 배달 W_node.js (0) | 2022.06.15 |
[알고리즘]백준 10250번: ACM 호텔 W_node.js (0) | 2022.06.10 |
[알고리즘]백준 2869번: 달팽이는 올라가고 싶다 W_node.js (0) | 2022.06.08 |