How can we calculate weighted cumulative sum of squares with prefix range updates by one?
问题 Given an array A with n elements which starts with all 0 s and another array W also with n elements (all greater than 0 ), we want to perform the following operation repeatedly; For a given k, increment A[0], A[1], .... A[k] each by 1, and report the value of A[0]^2 * W[0] + A[1]^2 * W[1] + ... + A[n-1]^2 * W[n-1] . Looking for an O(log n) solution (per query), or faster. 来源: https://stackoverflow.com/questions/61122170/how-can-we-calculate-weighted-cumulative-sum-of-squares-with-prefix-range