#C13243. Weighted Dot Product with Scaling
Weighted Dot Product with Scaling
Weighted Dot Product with Scaling
You are given three vectors a, b, and w of equal length. Your task is to compute the weighted dot product defined by:
\(\sum_{i=0}^{n-1} (a_i \times w_i) \times (b_i \times w_i)\)
If the three vectors do not have the same length, output the error message:
All input vectors must have the same length.
The input is provided via standard input and the result (or error message) should be printed to standard output.
inputFormat
The input consists of three lines. Each line contains space-separated numbers representing a vector. The first line is vector a, the second is vector b, and the third is vector w. All three vectors should have the same length.
outputFormat
Output a single number representing the weighted dot product computed as: (\sum_{i=0}^{n-1} (a_i \times w_i) \times (b_i \times w_i)). If the vectors do not have the same length, output exactly "All input vectors must have the same length.".## sample
1 2 3
4 5 6
2 0.5 1
36.5