-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_BigInteger.java
More file actions
41 lines (28 loc) · 1.06 KB
/
Java_BigInteger.java
File metadata and controls
41 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*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.
Input Format
There will be two lines containing two numbers, a and b.
Constraints
a and b are non-negative integers and can have maximum 200 digits.
Output Format
Output two lines. The first line should contain a+b, and the second line should contain a*b. Don't print any leading zeros.
Sample Input
1234
20
Sample Output
1254
24680 */
//SOLUTION//
import java.util.*;
import java.math.*;
public class Solution {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s1,s2;
s1=input.nextLine();
s2=input.nextLine();
input.close();
System.out.println(new BigInteger(s1).add(new BigInteger(s2)));
System.out.println(new BigInteger(s1).multiply(new BigInteger(s2)));
}
}