Javascript + Typescript/자바스크립트로 알고리즘풀기
[백준] 22193
치춘
2022. 7. 17. 22:13
Multiply
문제
Write a program that computes a product of two non-negative integers A and B. The integers are represented in decimal notation and have N and M digits, respectively.
입력
The first line contains the lengths N and M, separated by a space. A is given on the second and B on the third line. The numbers will not have leading zeros.
출력
Output the product of A and B without leading zeros.
제한
- 1 ≤ N, M ≤ 50,000
풀이
const multiply = () => {
let [[a, b], [n], [m]] = require("fs")
.readFileSync("/dev/stdin")
.toString()
.trim()
.split("\n")
.map((v) => v.split(" ").map(BigInt));
console.log((n * m).toString());
};
multiply();
반성회
50000자리까지 나올 수 있어서 아마 BigInt 아니면 힘들듯
그래서 그런가 C로 푼 문제 보면 엄청 복잡하다
속도 제일 빠른 답안중에 C로 푼 8ms짜리가 있는데 코드 열어보니까 진짜 경이롭다 푸리에 변환까지 나온다