Java BigInteger

  • + 0 comments

    Constraints a and b are non-negative integers and can have maximum 200 digits.

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        BigInteger x = BigInteger.valueOf(0);
        BigInteger a = new BigInteger(sc.next());
        BigInteger b = new BigInteger(sc.next());
    
        if(a.bitLength() < 200 && b.bitLength() < 200 && x.compareTo(a) < 0 && x.compareTo(b) < 0) 
            System.out.println(a.add(b));
            System.out.println(a.multiply(b));
    
    }
    

    }