[Java | 백준 13277번] 큰 수 곱셈
· 테크· Java
Java
백준 13277번 www.acmicpc.net/problem/13277
풀이
큰 수의 곱셈을 할 때에는 java.math에 있는 BigDecimal 타입을 사용해서 계산한다. 스캐너로 받을 때도 .nextBigInteger(); 와 같이 해주면 되고, 사칙연산은 연산자가 아닌 내장 메서드를 통해 .multiply() 로 계산한다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import java.math.*;
import java.util.*;
public class codinginteview_13277 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
sc.nextLine();
System.out.println(a.multiply(b));
sc.close();
}
}
|
cs |
Comments
No comments yet. Be the first!
319 posts in 테크
- 368Supabase 프로젝트 복사하기 (Restore to a New Project)NEW
- 341Migrating from Permanent Access Tokens to Token Exchange — Why Order Matters
- 326Startup & Product Glossary: Terms Every Solo Founder Should Know
- 325Context Management — How I Do It Now
- 324Claude Code Routines vs Cowork Schedule — What's the Difference?
1–5 / 319