<\/span><\/h2>\n\n\n\nIn 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.<\/p>\n\n\n\n
Use the power of Java’s BigInteger class and solve this problem.<\/p>\n\n\n\n
<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nThere will be two lines containing two numbers, a <\/em><\/strong>and b<\/em><\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h4>\n\n\n\na <\/em><\/strong>and b <\/em><\/strong>are non-negative integers and can have maximum 200 <\/strong>digits.<\/p>\n\n\n\n<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nOutput two lines. The first line should contain a + b<\/em><\/strong>, and the second line should contain a <\/em><\/strong>x<\/em> b<\/em><\/strong>. Don’t print any leading zeros.<\/p>\n\n\n\n<\/span>Sample Input<\/strong><\/span><\/h4>\n\n\n\n 1234\n 20<\/code><\/pre>\n\n\n\n<\/span>Sample Output<\/strong><\/span><\/h4>\n\n\n\n 1254\n 24680<\/code><\/pre>\n\n\n\n<\/span>Explanation<\/strong><\/span><\/h4>\n\n\n\n1234 + 20 = 1254<\/strong><\/p>\n\n\n\n1234 x 20 = 24680<\/strong><\/p>\n\n\n\n<\/span>Solution –<\/strong> Java BigDecimal<\/strong><\/span><\/h2>\n\n\n\nimport java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n\n public static void main(String[] args) {\n \/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. *\/\n Scanner sc = new Scanner(System.in);\n BigInteger a = new BigInteger(sc.nextLine());\n BigInteger b = new BigInteger(sc.nextLine());\n BigInteger sum = a.add(b);\n BigInteger prod = a.multiply(b);\n \n System.out.println(sum+\"\\n\"+prod);\n }\n}<\/pre>\n\n\n\n