Large Integer Arithmetic

Time limit2sMemory limit128 MB

Summary
Compute the sum, difference, and product of two signed integers up to 1000 digits without built-in bignum support.
Level

Medium4 of 10

Topics
Math, String, Implementation
Solved
No attempts yet

Problem

Given two integers A and B, write a program that calculates A+B, A-B, and A×B.

Input

The first line contains integer A, and the second line contains integer B. Each number is written in decimal notation, has at most 1,000 digits, and may be positive or negative.

Output

Print A+B on the first line, A-B on the second line, and A×B on the third line. Except when the value is 0, an output value must not begin with 0.

Examples1

  1. Example 1

    Input
    1
    -1
    
    Expected output
    0
    2
    -1