Algorithm & 자료구조/알고리즘 w.JavaScript
[알고리즘]백준 10757번: 큰 수 A+B W_node.js
프라이D
2022. 6. 16. 09:31
문제
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를 활용하여 풀었다.