-
<백준(node.js)> 10757번: 큰 수 A+B유물/└ 백준 2022. 2. 21. 17:27728x90
🤖
문제
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'유물 > └ 백준' 카테고리의 다른 글
<백준(파이썬)> 1068번: 트리 (0) 2022.03.23 <백준(node.js)> 1978번: 소수 찾기 (0) 2022.02.22 <백준(node.js)> 2839번: 설탕 배달 (0) 2022.02.20 <백준(node.js)> 2775번: 부녀회장이 될테야 (0) 2022.02.19 <백준(node.js)> 10250번: ACM 호텔 (0) 2022.02.17