HackerRank Java- BigInteger
In this problem, you have to add and multiply huge numbers! These numbers are so big that you can't contain them in any ordinary data types like a long integer.
Use the power of Java's BigInteger class and solve this problem.
- import java.io.*;
- import java.util.*;
- import java.text.*;
- import java.math.*;
- import java.util.regex.*;
-
- public class Solution {
-
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- BigInteger x = new BigInteger(scan.next());
- BigInteger y = new BigInteger(scan.next());
- System.out.println(x.add(y));
- System.out.println(x.multiply(y));
- }
- }