유물/└ 백준
<백준(node.js)> 10757번: 큰 수 A+B
디벅잉
2022. 2. 21. 17:27
728x90
🤖
문제
https://www.acmicpc.net/problem/10757
10757번: 큰 수 A+B
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
www.acmicpc.net
풀이
const filePath = process.platform === "linux" ? "/dev/stdin" : "../input.txt";
const INPUT_ARR = require("fs").readFileSync(filePath).toString().trim().split(" ");
console.log(
INPUT_ARR.reduce((pre, cur) => BigInt(pre) + BigInt(cur)).toString()
);
1. (line 5) 주어진 숫자 2개를 BigInt형으로 만들고 더합니다. BigInt형이라 숫자 마지막에 n이 붙으므로 문자열로 변환하여 n을 제거합니다.
📌
https://nyang-in.tistory.com/176
[백준] 10757. 큰 수 A+B (자바스크립트/node.js/javascript/알고리즘/코딩테스트)
[백준] 10757. 큰 수 A+B 첫째 줄에 A와 B가 주어진다. (0 < A,B < 10^10000) A+B의 값을 출력하면 되는 문제이다. 예제 입력 : 9223372036854775807 9223372036854775808 예제 출력 : 18446744073709551615..
nyang-in.tistory.com
728x90