Java BigInteger Hackerrank Solution
For Explanation Watch Video:
Sample Input
1234
20
Sample Output
1254
24680
Code:
import java.io.*;import java.util.*;import java.math.*;public class Solution {
public static void main(String[] args) { Scanner scn = new Scanner(System.in); BigInteger a; BigInteger b; a = new BigInteger(scn.nextLine()); b = new BigInteger(scn.nextLine()); BigInteger sum = BigInteger.valueOf(0); BigInteger product = BigInteger.valueOf(0); sum = sum.add(a); sum = sum.add(b); System.out.println(sum); product = a.multiply(b); System.out.println(product); }}
Comments
Post a Comment