The inner product of two integer sequences (or vectors) of the same length is defined as follows:
<A, B> =A[1]*B[1] + A[2]*B[2] + ... + A[n]*B[n]
You are going to calculate the inner product of two variable integer sequences. At the beginning, all elements of both sequences are zeros. Then several operations are applied to the sequences in turn. There are three types of operations:
SET X i j k
This operation sets X[i], X[i+1] ... X[j] to k. 1<= i, j <= n, 0 <= k <=1000000000.
ADD X i j k
This operation adds k to each of X[i], X[i+1] ... X[j]. 1<= i, j <= n, 0 <= k <=1000000000.
SWAP i j
This operations waps A[t] and B[t], t = i, i+1 ... J. 1<= i, j <= n.
Please calculate the inner product of A and B after every operation.
5 5 ADD A 1 2 3 SET B 2 3 4 SWAP 3 5 ADD B 3 4 5 SET A 4 5 1
0 12 12 32 37
本文介绍了如何计算两个整数序列的内积,并通过多种操作(设置、加法、交换)来修改序列值,最终输出每次操作后的内积结果。
1135

被折叠的 条评论
为什么被折叠?



