Problem 226
Multiply Strings
Medium · 20 pts · String, Math, Simulation
Problem
You are given two non-negative integers A and B as strings of digits. They can have up to 200 digits, which is far beyond any built-in integer type, so you cannot just convert them. Print the product A × B, without leading zeros (the product of anything with 0 is 0). Do long multiplication as on paper: the digit at position i of A times the digit at position j of B contributes to position i + j of the result. Add all these contributions into an array and then propagate the carries.
Input
Two lines: the numbers A and B (digits only, no leading zeros unless the number is 0).
Output
Print A * B.
Constraints
1 <= length of A, B <= 200
Example input
123 456
Example output
56088
Explanation
123 × 456: 123 × 6 = 738, 123 × 50 = 6150 and 123 × 400 = 49200. Adding them gives 738 + 6150 + 49200 = 56088.