[백준2338_자바스크립트(javascript)] - 긴자리 계산

경이·2024년 10월 24일

𝑩𝑶𝑱 (𝒋𝒔)

목록 보기
232/325

🔴 문제

긴자리 계산


🟡 Sol

const fs = require('fs');
const path = process.platform === 'linux' ? '/dev/stdin' : 'Wiki\\input.txt';
const [a, b] = fs
  .readFileSync(path, 'utf-8')
  .trim()
  .split('\n')
  .map(BigInt);

console.log((a+b).toString());
console.log((a-b).toString());
console.log((a*b).toString());

🟢 풀이

⏰ 소요한 시간 : -

자바스크릡트에서 16자리 이상의 큰 수를 다룰때는 number 타입이 아닌 BigInt 타입으로 다룬다.


🔵 Ref

profile
록타르오가르

0개의 댓글