Time limit
2s
Memory limit
256 MB
You are given two non-negative integers A and B. Instead of ordinary multiplication, define a new value as follows: choose one digit from A and one digit from B, multiply those two digits, and add the products over every possible pair of chosen digits.
If A has n digits and B has m digits, there are n × m pairs. For 121 and 34, the calculation is:
1×3 + 1×4 + 2×3 + 2×4 + 1×3 + 1×4 = 28Compute this value for the two given numbers.
The first line contains two non-negative integers A and B, separated by a space. Each number has at most 10,000 digits.
If a number is zero, it is given as exactly 0. Otherwise, a number does not start with 0.
Print the multiplication result defined in the statement.
1×3 + 1×4 + 2×3 + 2×4 + 1×3 + 1×4 = 28