#C13224. Element-wise Product of Two Arrays
Element-wise Product of Two Arrays
Element-wise Product of Two Arrays
You are given two arrays of integers. Your task is to compute a new array where each element is the product of the corresponding elements from the two arrays.
Formally, given two arrays \( A = [a_1, a_2, \dots, a_n] \) and \( B = [b_1, b_2, \dots, b_m] \), if \( n = m \), you should output the array \( C = [a_1\times b_1, a_2\times b_2, \dots, a_n\times b_n] \). If the arrays have different lengths, output the error message: "Error: Both lists must have the same number of elements".
The input is read from stdin and the result should be printed to stdout.
inputFormat
The input consists of four lines:
- The first line contains an integer \(n\), the number of elements in the first array.
- The second line contains \(n\) space-separated integers representing the first array. (If \(n = 0\), this line will be empty.)
- The third line contains an integer \(m\), the number of elements in the second array.
- The fourth line contains \(m\) space-separated integers representing the second array. (If \(m = 0\), this line will be empty.)
If \(n \neq m\), the program should output the error message.
outputFormat
If the two arrays have the same length, output a single line with the element-wise product of the two arrays, with each number separated by a single space. If the arrays have different lengths, output the exact error message:
Error: Both lists must have the same number of elements## sample
4
1 2 3 4
4
5 6 7 8
5 12 21 32
</p>