#K54342. Multiply Strings

    ID: 29732 Type: Default 1000ms 256MiB

Multiply Strings

Multiply Strings

You are given two non-negative integers represented as strings. Your task is to implement multiplication of these two numbers without converting them directly to integers or using any built-in BigInteger library. Instead, simulate the manual multiplication process, similar to how you perform multiplication by hand.

The basic idea is to multiply each digit of the first number with each digit of the second number and sum up the results carefully, taking care of the carry. One of the key formulas used during the multiplication is:

$$result[i+j+1] = (num1[i]-'0') \times (num2[j]-'0') + result[i+j+1]$$

After processing all digits, remove any leading zeros from the final result. The inputs might be very large, so efficiency and careful manipulation of digits is important.

inputFormat

The input consists of two lines:

  • The first line contains a string representing the first non-negative integer.
  • The second line contains a string representing the second non-negative integer.

outputFormat

Output a single line that contains the product of the two numbers as a string.

## sample
123
456
56088